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

26 lines
1.0 KiB
TypeScript
Raw Normal View History

2018-01-29 23:09:54 +00:00
import { expect } from "chai";
import { Formatter } from "@export/formatter";
2018-10-26 01:04:07 +01:00
import { PageOrientation, PageSize } from "./page-size";
2018-01-29 23:09:54 +00:00
describe("PageSize", () => {
describe("#constructor()", () => {
it("should create page size with portrait", () => {
const properties = new PageSize(100, 200, 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 = new PageSize(100, 200, 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
});
});
});