Files
github-stats-extended/apps/backend/tests/flexLayout.test.js
T
Marco Pasqualettiandmartin-mfg 8c065b473f feat: setup monorepo using pnpm (#20)
* tests: fix float problems and PAT problem

* extend CONTRIBUTING.md

* extend build documentation, add GH action, fix build on MacOS

* fix build on Vercel

* update .gitignore and CONTRIBUTING.md

* feat: begin work on monorepo

* chore(actions/basic-build): use pnpm

* fix: vercel-deploy

* docs: updates with new folders

* chore: apply PR review comments

---------

Co-authored-by: martin-mfg <2026226+martin-mfg@users.noreply.github.com>
2026-01-19 14:11:58 +01:00

48 lines
1.3 KiB
JavaScript

import { describe, expect, it } from "@jest/globals";
import { flexLayout } from "../src/common/render.js";
describe("flexLayout", () => {
it("should work with row & col layouts", () => {
const layout = flexLayout({
items: ["<text>1</text>", "<text>2</text>"],
gap: 60,
});
expect(layout).toStrictEqual([
`<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",
});
expect(columns).toStrictEqual([
`<g transform="translate(0, 0)"><text>1</text></g>`,
`<g transform="translate(0, 60)"><text>2</text></g>`,
]);
});
it("should work with sizes", () => {
const layout = flexLayout({
items: [
"<text>1</text>",
"<text>2</text>",
"<text>3</text>",
"<text>4</text>",
],
gap: 20,
sizes: [200, 100, 55, 25],
});
expect(layout).toStrictEqual([
`<g transform="translate(0, 0)"><text>1</text></g>`,
`<g transform="translate(220, 0)"><text>2</text></g>`,
`<g transform="translate(340, 0)"><text>3</text></g>`,
`<g transform="translate(415, 0)"><text>4</text></g>`,
]);
});
});