refactor: added FlexLayout for flex layouts

This commit is contained in:
anuraghazra
2020-07-18 22:44:27 +05:30
parent 06f0021660
commit 253eb39b19
6 changed files with 122 additions and 42 deletions

View File

@@ -1,4 +1,9 @@
const { kFormatter, encodeHTML, renderError } = require("../src/utils");
const {
kFormatter,
encodeHTML,
renderError,
FlexLayout,
} = require("../src/utils");
describe("Test utils.js", () => {
it("should test kFormatter", () => {
@@ -23,4 +28,25 @@ describe("Test utils.js", () => {
"Something went wrong"
);
});
it("should test FlexLayout", () => {
const layout = FlexLayout({
items: ["<text>1</text>", "<text>2</text>"],
gap: 60,
}).join("");
expect(layout).toBe(
`<g transform=\"translate(0, 0)\"><text>1</text></g><g transform=\"translate(60, 0)\"><text>2</text></g>`
);
const columns = FlexLayout({
items: ["<text>1</text>", "<text>2</text>"],
gap: 60,
direction: "column",
}).join("");
expect(columns).toBe(
`<g transform=\"translate(0, 0)\"><text>1</text></g><g transform=\"translate(0, 60)\"><text>2</text></g>`
);
});
});