Files
docx-js/src/file/document/body/section-properties/properties/page-size.spec.ts

26 lines
1.1 KiB
TypeScript
Raw Normal View History

2023-06-05 00:33:43 +01:00
import { describe, expect, it } from "vitest";
2018-01-29 23:09:54 +00:00
import { Formatter } from "@export/formatter";
2018-10-26 01:04:07 +01:00
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", () => {
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"]);
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", () => {
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"]);
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
});
});
});