Files
docx-js/src/file/document/body/body.spec.ts

50 lines
1.7 KiB
TypeScript
Raw Normal View History

import { assert } from "chai";
import { Utility } from "../../../tests/utility";
import { Body } from "./";
2018-01-24 00:01:38 +00:00
import { Columns } from "./section-properties/columns/columns";
import { DocumentGrid } from "./section-properties/doc-grid/doc-grid";
import { PageMargin } from "./section-properties/page-margin/page-margin";
import { PageSize } from "./section-properties/page-size/page-size";
import { SectionProperties } from "./section-properties/section-properties";
2016-03-31 23:01:20 +01:00
2016-04-03 05:24:56 +01:00
describe("Body", () => {
2016-05-26 15:08:34 +01:00
let body: Body;
2016-03-31 23:01:20 +01:00
beforeEach(() => {
body = new Body();
2018-01-24 00:01:38 +00:00
body.push(new SectionProperties(0));
body.push(new PageSize(0, 0));
body.push(new PageMargin(0, 0, 0, 0, 0, 0, 0));
body.push(new Columns(0));
body.push(new DocumentGrid(0));
2016-03-31 23:01:20 +01:00
});
2016-04-04 17:30:29 +01:00
describe("#constructor()", () => {
2016-04-01 00:22:44 +01:00
it("should create the Section Properties", () => {
2017-03-09 22:31:55 +00:00
const newJson = Utility.jsonify(body);
2016-05-02 22:39:03 +01:00
assert.equal(newJson.root[0].rootKey, "w:sectPr");
2016-04-01 00:22:44 +01:00
});
it("should create the Page Size", () => {
2017-03-09 22:31:55 +00:00
const newJson = Utility.jsonify(body);
2016-05-02 22:39:03 +01:00
assert.equal(newJson.root[1].rootKey, "w:pgSz");
2016-04-01 00:22:44 +01:00
});
it("should create the Page Margin", () => {
2017-03-09 22:31:55 +00:00
const newJson = Utility.jsonify(body);
2016-05-02 22:39:03 +01:00
assert.equal(newJson.root[2].rootKey, "w:pgMar");
2016-04-01 00:22:44 +01:00
});
it("should create the Columns", () => {
2017-03-09 22:31:55 +00:00
const newJson = Utility.jsonify(body);
2016-05-02 22:39:03 +01:00
assert.equal(newJson.root[3].rootKey, "w:cols");
2016-04-01 00:22:44 +01:00
});
it("should create the Document Grid", () => {
2017-03-09 22:31:55 +00:00
const newJson = Utility.jsonify(body);
2016-05-02 22:39:03 +01:00
assert.equal(newJson.root[4].rootKey, "w:docGrid");
});
2016-03-31 23:01:20 +01:00
});
2017-03-09 22:31:55 +00:00
});