diff --git a/src/file/document/body/section-properties/page-size/page-size.spec.ts b/src/file/document/body/section-properties/page-size/page-size.spec.ts new file mode 100644 index 0000000000..4ebcf989c0 --- /dev/null +++ b/src/file/document/body/section-properties/page-size/page-size.spec.ts @@ -0,0 +1,26 @@ +import { expect } from "chai"; + +import { Formatter } from "../../../../../export/formatter"; +import { PageSize } from "./page-size"; + +describe("PageSize", () => { + describe("#constructor()", () => { + it("should create page size with portrait", () => { + const properties = new PageSize(100, 200, "portrait"); + const tree = new Formatter().format(properties); + + expect(Object.keys(tree)).to.deep.equal(["w:pgSz"]); + expect(tree["w:pgSz"]).to.be.an.instanceof(Array); + expect(tree["w:pgSz"][0]).to.deep.equal({ _attr: { "w:h": 200, "w:w": 100, "w:orient": "portrait" } }); + }); + + it("should create page size with horizontal and invert the lengths", () => { + const properties = new PageSize(100, 200, "landscape"); + const tree = new Formatter().format(properties); + + expect(Object.keys(tree)).to.deep.equal(["w:pgSz"]); + expect(tree["w:pgSz"]).to.be.an.instanceof(Array); + expect(tree["w:pgSz"][0]).to.deep.equal({ _attr: { "w:h": 100, "w:w": 200, "w:orient": "landscape" } }); + }); + }); +});