Add and fix tests

This commit is contained in:
Dolan
2018-01-31 23:24:55 +00:00
parent c895a9c7d9
commit 2f0ad3eeb2
5 changed files with 36 additions and 9 deletions

View File

@ -1,13 +1,13 @@
// import { assert } from "chai"; // import { assert } from "chai";
// import { Utility } from "../../../tests/utility"; // import { Utility } from "../../../tests/utility";
import { Body } from "./"; // import { Body } from "./";
describe("Body", () => { describe("Body", () => {
let body: Body; // let body: Body;
beforeEach(() => { beforeEach(() => {
body = new Body(); // body = new Body();
}); });
// describe("#constructor()", () => { // describe("#constructor()", () => {

View File

@ -15,10 +15,9 @@ describe("Document", () => {
describe("#constructor()", () => { describe("#constructor()", () => {
it("should create valid JSON", () => { it("should create valid JSON", () => {
const stringifiedJson = JSON.stringify(document); const stringifiedJson = JSON.stringify(document);
let newJson;
try { try {
newJson = JSON.parse(stringifiedJson); JSON.parse(stringifiedJson);
} catch (e) { } catch (e) {
assert.isTrue(false); assert.isTrue(false);
} }

View File

@ -17,10 +17,9 @@ describe("ThematicBreak", () => {
describe("#constructor()", () => { describe("#constructor()", () => {
it("should create valid JSON", () => { it("should create valid JSON", () => {
const stringifiedJson = JSON.stringify(thematicBreak); const stringifiedJson = JSON.stringify(thematicBreak);
let newJson;
try { try {
newJson = JSON.parse(stringifiedJson); JSON.parse(stringifiedJson);
} catch (e) { } catch (e) {
assert.isTrue(false); assert.isTrue(false);
} }

View File

@ -14,10 +14,9 @@ describe("Paragraph", () => {
describe("#constructor()", () => { describe("#constructor()", () => {
it("should create valid JSON", () => { it("should create valid JSON", () => {
const stringifiedJson = JSON.stringify(paragraph); const stringifiedJson = JSON.stringify(paragraph);
let newJson;
try { try {
newJson = JSON.parse(stringifiedJson); JSON.parse(stringifiedJson);
} catch (e) { } catch (e) {
assert.isTrue(false); assert.isTrue(false);
} }

View File

@ -0,0 +1,30 @@
// tslint:disable:no-string-literal
import { expect } from "chai";
import { Formatter } from "../../export/formatter";
import { Relationships } from "./relationships";
describe("Relationships", () => {
describe("#constructor()", () => {
it("should create section properties with options", () => {
const properties = new Relationships();
const tree = new Formatter().format(properties);
expect(Object.keys(tree)).to.deep.equal(["Relationships"]);
expect(tree["Relationships"]).to.be.an.instanceof(Array);
expect(tree["Relationships"][0]).to.deep.equal({
_attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" },
});
expect(tree["Relationships"][1]).to.deep.equal({
Relationship: [
{
_attr: {
Id: "rId1",
Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",
Target: "styles.xml",
},
},
],
});
});
});
});