rearranged test locations

This commit is contained in:
Dolan Miu
2016-07-01 22:09:55 +01:00
parent 10554956f2
commit 8ecb8ed8f2
13 changed files with 101 additions and 49 deletions

View File

@ -0,0 +1,55 @@
/// <reference path="../../../typings/mocha/mocha.d.ts" />
/// <reference path="../../../typings/chai/chai.d.ts" />
import {Body} from "../../../docx/document/body";
import {assert} from "chai";
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";
function jsonify(obj: Object) {
let stringifiedJson = JSON.stringify(obj);
return JSON.parse(stringifiedJson);
}
describe("Body", () => {
let body: Body;
beforeEach(() => {
body = new Body();
body.push(new SectionProperties());
body.push(new PageSize());
body.push(new PageMargin());
body.push(new Columns());
body.push(new DocumentGrid());
});
describe("#constructor()", () => {
it("should create the Section Properties", () => {
let newJson = jsonify(body);
assert.equal(newJson.root[0].rootKey, "w:sectPr");
});
it("should create the Page Size", () => {
let newJson = jsonify(body);
assert.equal(newJson.root[1].rootKey, "w:pgSz");
});
it("should create the Page Margin", () => {
let newJson = jsonify(body);
assert.equal(newJson.root[2].rootKey, "w:pgMar");
});
it("should create the Columns", () => {
let newJson = jsonify(body);
assert.equal(newJson.root[3].rootKey, "w:cols");
});
it("should create the Document Grid", () => {
let newJson = jsonify(body);
assert.equal(newJson.root[4].rootKey, "w:docGrid");
});
});
});

View File

@ -0,0 +1,28 @@
/// <reference path="../../../typings/mocha/mocha.d.ts" />
/// <reference path="../../../typings/chai/chai.d.ts" />
import * as docx from "../../../docx";
import {assert} from "chai";
describe("Document", () => {
let document: docx.Document;
beforeEach(() => {
document = new docx.Document();
});
describe("#constructor()", () => {
it("should create valid JSON", () => {
let stringifiedJson = JSON.stringify(document);
let newJson;
try {
newJson = JSON.parse(stringifiedJson);
} catch (e) {
assert.isTrue(false);
}
assert.isTrue(true);
});
});
});

View File

@ -0,0 +1,41 @@
/// <reference path="../../../../typings/mocha/mocha.d.ts" />
/// <reference path="../../../../typings/chai/chai.d.ts" />
import {Attributes} from "../../../../docx/xml-components";
import {assert} from "chai";
describe("Attribute", () => {
let attributes: Attributes;
beforeEach(() => {
attributes = new Attributes();
});
describe("#constructor()", () => {
it("should not add val with empty constructor", () => {
let newAttrs = new Attributes();
let stringifiedJson = JSON.stringify(newAttrs);
let newJson = JSON.parse(stringifiedJson);
assert.isUndefined(newJson.root.val);
});
it("should have val as defined with populated constructor", () => {
let newAttrs = new Attributes({
val: "test"
});
let stringifiedJson = JSON.stringify(newAttrs);
let newJson = JSON.parse(stringifiedJson);
assert.equal(newJson.root.val, "test");
});
it("should have space value as defined with populated constructor", () => {
let newAttrs = new Attributes({
space: "spaceTest"
});
let stringifiedJson = JSON.stringify(newAttrs);
let newJson = JSON.parse(stringifiedJson);
assert.equal(newJson.root.space, "spaceTest");
});
});
});