From 2f0ad3eeb28f8d12bfd24cd57a2888502ba34c81 Mon Sep 17 00:00:00 2001 From: Dolan Date: Wed, 31 Jan 2018 23:24:55 +0000 Subject: [PATCH] Add and fix tests --- src/file/document/body/body.spec.ts | 6 ++-- src/file/document/document.spec.ts | 3 +- src/file/paragraph/formatting/border.spec.ts | 3 +- src/file/paragraph/paragraph.spec.ts | 3 +- src/file/relationships/relationships.spec.ts | 30 ++++++++++++++++++++ 5 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 src/file/relationships/relationships.spec.ts diff --git a/src/file/document/body/body.spec.ts b/src/file/document/body/body.spec.ts index d69969931f..c5498bc99a 100644 --- a/src/file/document/body/body.spec.ts +++ b/src/file/document/body/body.spec.ts @@ -1,13 +1,13 @@ // import { assert } from "chai"; // import { Utility } from "../../../tests/utility"; -import { Body } from "./"; +// import { Body } from "./"; describe("Body", () => { - let body: Body; + // let body: Body; beforeEach(() => { - body = new Body(); + // body = new Body(); }); // describe("#constructor()", () => { diff --git a/src/file/document/document.spec.ts b/src/file/document/document.spec.ts index 99285fef21..218ff55a98 100644 --- a/src/file/document/document.spec.ts +++ b/src/file/document/document.spec.ts @@ -15,10 +15,9 @@ describe("Document", () => { describe("#constructor()", () => { it("should create valid JSON", () => { const stringifiedJson = JSON.stringify(document); - let newJson; try { - newJson = JSON.parse(stringifiedJson); + JSON.parse(stringifiedJson); } catch (e) { assert.isTrue(false); } diff --git a/src/file/paragraph/formatting/border.spec.ts b/src/file/paragraph/formatting/border.spec.ts index c2f09a288f..c86af41154 100644 --- a/src/file/paragraph/formatting/border.spec.ts +++ b/src/file/paragraph/formatting/border.spec.ts @@ -17,10 +17,9 @@ describe("ThematicBreak", () => { describe("#constructor()", () => { it("should create valid JSON", () => { const stringifiedJson = JSON.stringify(thematicBreak); - let newJson; try { - newJson = JSON.parse(stringifiedJson); + JSON.parse(stringifiedJson); } catch (e) { assert.isTrue(false); } diff --git a/src/file/paragraph/paragraph.spec.ts b/src/file/paragraph/paragraph.spec.ts index 048cca7d03..54c5970679 100644 --- a/src/file/paragraph/paragraph.spec.ts +++ b/src/file/paragraph/paragraph.spec.ts @@ -14,10 +14,9 @@ describe("Paragraph", () => { describe("#constructor()", () => { it("should create valid JSON", () => { const stringifiedJson = JSON.stringify(paragraph); - let newJson; try { - newJson = JSON.parse(stringifiedJson); + JSON.parse(stringifiedJson); } catch (e) { assert.isTrue(false); } diff --git a/src/file/relationships/relationships.spec.ts b/src/file/relationships/relationships.spec.ts new file mode 100644 index 0000000000..882d7e9db2 --- /dev/null +++ b/src/file/relationships/relationships.spec.ts @@ -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", + }, + }, + ], + }); + }); + }); +});