From f805d6bef70609be820ac02b4ee3142e109d802f Mon Sep 17 00:00:00 2001 From: Dolan Miu Date: Mon, 2 May 2016 22:39:03 +0100 Subject: [PATCH] fixed tests --- ts/tests/attributeTest.ts | 6 +++--- ts/tests/bodyTest.ts | 11 +++++------ ts/tests/borderTest.ts | 3 +-- ts/tests/localPackerTest.ts | 2 +- ts/tests/propertiesTest.ts | 3 +-- ts/tests/runTest.ts | 9 +++++---- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/ts/tests/attributeTest.ts b/ts/tests/attributeTest.ts index b293425a81..043658818f 100644 --- a/ts/tests/attributeTest.ts +++ b/ts/tests/attributeTest.ts @@ -16,7 +16,7 @@ describe("Attribute", () => { var newAttrs = new Attributes(); var stringifiedJson = JSON.stringify(newAttrs); var newJson = JSON.parse(stringifiedJson); - assert.isUndefined(newJson._attr.val); + assert.isUndefined(newJson.root.val); }); it("should have val as defined with populated constructor", () => { @@ -25,7 +25,7 @@ describe("Attribute", () => { }); var stringifiedJson = JSON.stringify(newAttrs); var newJson = JSON.parse(stringifiedJson); - assert(newJson._attr.val === "test"); + assert.equal(newJson.root.val, "test"); }); it("should have space value as defined with populated constructor", () => { @@ -34,7 +34,7 @@ describe("Attribute", () => { }); var stringifiedJson = JSON.stringify(newAttrs); var newJson = JSON.parse(stringifiedJson); - assert(newJson._attr.space === "spaceTest"); + assert.equal(newJson.root.space, "spaceTest"); }); }); }); \ No newline at end of file diff --git a/ts/tests/bodyTest.ts b/ts/tests/bodyTest.ts index 70aff66ca7..e941b7243c 100644 --- a/ts/tests/bodyTest.ts +++ b/ts/tests/bodyTest.ts @@ -29,28 +29,27 @@ describe("Body", () => { it("should create the Section Properties", () => { var newJson = jsonify(body); - console.log(newJson); - assert.isDefined(newJson.body[0].sectPr); + assert.equal(newJson.root[0].rootKey, "w:sectPr"); }); it("should create the Page Size", () => { var newJson = jsonify(body); - assert.isDefined(newJson.body[1].pgSz); + assert.equal(newJson.root[1].rootKey, "w:pgSz"); }); it("should create the Page Margin", () => { var newJson = jsonify(body); - assert.isDefined(newJson.body[2].pgMar); + assert.equal(newJson.root[2].rootKey, "w:pgMar"); }); it("should create the Columns", () => { var newJson = jsonify(body); - assert.isDefined(newJson.body[3].cols); + assert.equal(newJson.root[3].rootKey, "w:cols"); }); it("should create the Document Grid", () => { var newJson = jsonify(body); - assert.isDefined(newJson.body[4].docGrid); + assert.equal(newJson.root[4].rootKey, "w:docGrid"); }); }); }); \ No newline at end of file diff --git a/ts/tests/borderTest.ts b/ts/tests/borderTest.ts index b81e8d0633..940c183991 100644 --- a/ts/tests/borderTest.ts +++ b/ts/tests/borderTest.ts @@ -28,8 +28,7 @@ describe("ThematicBreak", () => { val: "single", sz: "6" }; - delete newJson.pBdr[0].bottom[0]._attr.xmlKeys; - assert(JSON.stringify(newJson.pBdr[0].bottom[0]._attr) === JSON.stringify(attributes)); + assert.equal(JSON.stringify(newJson.root[0].root[0].root), JSON.stringify(attributes)); }); }) }); \ No newline at end of file diff --git a/ts/tests/localPackerTest.ts b/ts/tests/localPackerTest.ts index b9eb1f3dea..b8d1b55265 100644 --- a/ts/tests/localPackerTest.ts +++ b/ts/tests/localPackerTest.ts @@ -25,7 +25,7 @@ describe("Packer", () => { packer = new LocalPacker(document, DefaultStyle(), properties, "build/tests/test.docx"); }); - describe.only('#pack()', () => { + describe('#pack()', () => { it("should create a standard docx file", (done) => { packer.pack(); diff --git a/ts/tests/propertiesTest.ts b/ts/tests/propertiesTest.ts index 9b304254d4..5f5b838895 100644 --- a/ts/tests/propertiesTest.ts +++ b/ts/tests/propertiesTest.ts @@ -21,8 +21,7 @@ describe("Properties", () => { title: "test document" }); var newJson = jsonify(properties); - - assert(newJson.coreProperties[1].title === "test document"); + assert(newJson.root[1].root === "test document"); }); }) }); \ No newline at end of file diff --git a/ts/tests/runTest.ts b/ts/tests/runTest.ts index e59efba185..8aefa2b759 100644 --- a/ts/tests/runTest.ts +++ b/ts/tests/runTest.ts @@ -20,7 +20,7 @@ describe("Run", () => { it("it should add bold to the properties", () => { run.bold(); var newJson = jsonify(run); - assert.isDefined(newJson.r[0].rPr[0].b); + assert.equal(newJson.root[0].root[0].rootKey, "w:b"); }); }); @@ -28,7 +28,7 @@ describe("Run", () => { it("it should add italics to the properties", () => { run.italics(); var newJson = jsonify(run); - assert.isDefined(newJson.r[0].rPr[0].i); + assert.equal(newJson.root[0].root[0].rootKey, "w:i"); }); }); @@ -36,7 +36,7 @@ describe("Run", () => { it("it should add underline to the properties", () => { run.underline(); var newJson = jsonify(run); - assert.isDefined(newJson.r[0].rPr[0].u); + assert.equal(newJson.root[0].root[0].rootKey, "w:u"); }); }); }); @@ -49,7 +49,8 @@ describe('TextRun', () => { it("should add text into run", () => { run = new TextRun("test"); var newJson = jsonify(run); - assert(newJson.r[1].t === "test"); + console.log(newJson.root[1].root) + assert.equal(newJson.root[1].root, "test"); }); }); }); \ No newline at end of file