2023-06-05 00:33:43 +01:00
|
|
|
import { describe, expect, it } from "vitest";
|
2018-01-29 23:09:54 +00:00
|
|
|
|
2022-06-26 23:26:42 +01:00
|
|
|
import { Formatter } from "@export/formatter";
|
2018-10-26 01:04:07 +01:00
|
|
|
|
2025-04-14 16:43:15 +05:30
|
|
|
import { PageOrientation, createPageSize } from "./page-size";
|
2018-01-29 23:09:54 +00:00
|
|
|
|
|
|
|
describe("PageSize", () => {
|
|
|
|
describe("#constructor()", () => {
|
|
|
|
it("should create page size with portrait", () => {
|
2025-04-14 16:43:15 +05:30
|
|
|
const properties = createPageSize({ width: 100, height: 200, orientation: PageOrientation.PORTRAIT });
|
2018-01-29 23:09:54 +00:00
|
|
|
const tree = new Formatter().format(properties);
|
|
|
|
|
|
|
|
expect(Object.keys(tree)).to.deep.equal(["w:pgSz"]);
|
2019-04-09 05:27:18 -04:00
|
|
|
expect(tree["w:pgSz"]).to.deep.equal({ _attr: { "w:h": 200, "w:w": 100, "w:orient": "portrait" } });
|
2018-01-29 23:09:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should create page size with horizontal and invert the lengths", () => {
|
2025-04-14 16:43:15 +05:30
|
|
|
const properties = createPageSize({ width: 100, height: 200, orientation: PageOrientation.LANDSCAPE });
|
2018-01-29 23:09:54 +00:00
|
|
|
const tree = new Formatter().format(properties);
|
|
|
|
|
|
|
|
expect(Object.keys(tree)).to.deep.equal(["w:pgSz"]);
|
2019-04-09 05:27:18 -04:00
|
|
|
expect(tree["w:pgSz"]).to.deep.equal({ _attr: { "w:h": 100, "w:w": 200, "w:orient": "landscape" } });
|
2018-01-29 23:09:54 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|