2018-01-29 23:09:54 +00:00
|
|
|
import { expect } from "chai";
|
|
|
|
|
2018-10-26 01:04:07 +01:00
|
|
|
import { Formatter } from "export/formatter";
|
|
|
|
|
2018-01-29 23:09:54 +00:00
|
|
|
import { PageSize } from "./page-size";
|
2018-06-21 12:03:34 +02:00
|
|
|
import { PageOrientation } from "./page-size-attributes";
|
2018-01-29 23:09:54 +00:00
|
|
|
|
|
|
|
describe("PageSize", () => {
|
|
|
|
describe("#constructor()", () => {
|
|
|
|
it("should create page size with portrait", () => {
|
2018-06-21 12:03:34 +02:00
|
|
|
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"]);
|
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", () => {
|
2018-06-21 12:03:34 +02:00
|
|
|
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"]);
|
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
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|