2016-03-31 23:01:20 +01:00
|
|
|
/// <reference path="../typings/mocha/mocha.d.ts" />
|
|
|
|
/// <reference path="../typings/chai/chai.d.ts" />
|
|
|
|
import {Body} from "../docx/document/body";
|
|
|
|
import {assert} from "chai";
|
2016-04-09 04:53:42 +01:00
|
|
|
import {SectionProperties} from "../docx/document/body/section-properties";
|
|
|
|
import {PageSize} from "../docx/document/body/page-size";
|
|
|
|
import {PageMargin} from "../docx/document/body/page-margin";
|
|
|
|
import {Columns} from "../docx/document/body/columns";
|
|
|
|
import {DocumentGrid} from "../docx/document/body/doc-grid";
|
2016-03-31 23:01:20 +01:00
|
|
|
|
|
|
|
function jsonify(obj: Object) {
|
|
|
|
var stringifiedJson = JSON.stringify(obj);
|
|
|
|
return JSON.parse(stringifiedJson);
|
|
|
|
}
|
|
|
|
|
2016-04-03 05:24:56 +01:00
|
|
|
describe("Body", () => {
|
2016-03-31 23:01:20 +01:00
|
|
|
var body: Body;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
body = new Body();
|
2016-04-09 04:53:42 +01:00
|
|
|
body.push(new SectionProperties());
|
|
|
|
body.push(new PageSize());
|
|
|
|
body.push(new PageMargin());
|
|
|
|
body.push(new Columns());
|
|
|
|
body.push(new DocumentGrid());
|
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", () => {
|
|
|
|
var newJson = 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", () => {
|
|
|
|
var newJson = 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", () => {
|
|
|
|
var newJson = 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", () => {
|
|
|
|
var newJson = 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", () => {
|
|
|
|
var newJson = jsonify(body);
|
2016-05-02 22:39:03 +01:00
|
|
|
assert.equal(newJson.root[4].rootKey, "w:docGrid");
|
2016-03-31 23:36:42 +01:00
|
|
|
});
|
2016-03-31 23:01:20 +01:00
|
|
|
});
|
|
|
|
});
|