From c608d035569e16c81ea29ecf2a904e227379cecd Mon Sep 17 00:00:00 2001 From: jaceyshome Date: Thu, 21 May 2015 21:14:15 +1000 Subject: styles names should be null by default --- tests/docx/styles-reader.tests.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') diff --git a/tests/docx/styles-reader.tests.js b/tests/docx/styles-reader.tests.js index 7899b1b..f76dfc2 100644 --- a/tests/docx/styles-reader.tests.js +++ b/tests/docx/styles-reader.tests.js @@ -59,6 +59,17 @@ describe('readStylesXml', function() { }); assert.equal(styles.findParagraphStyleById("Heading1").name, "Heading 1"); }); + + test('styles names should be null by default', function() { + var styles = readStylesXml({ + root: new XmlElement("w:styles", {}, [ + paragraphStyleElement("Heading1", null), + characterStyleElement("Heading1Char", null) + ]) + }); + assert.equal(styles.findParagraphStyleById("Heading1Char"), null); + assert.equal(styles.findCharacterStyleById("Heading1"), null); + }); }); function paragraphStyleElement(id, name) { -- cgit v1.2.3 From 429af29e958c8084d27f39a3c9685c043d1f6df3 Mon Sep 17 00:00:00 2001 From: jaceyshome Date: Sat, 23 May 2015 11:55:25 +1000 Subject: fixed styles reader text case: 'styles names should be null by default' --- tests/docx/styles-reader.tests.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/docx/styles-reader.tests.js b/tests/docx/styles-reader.tests.js index f76dfc2..bd28673 100644 --- a/tests/docx/styles-reader.tests.js +++ b/tests/docx/styles-reader.tests.js @@ -61,15 +61,16 @@ describe('readStylesXml', function() { }); test('styles names should be null by default', function() { - var styles = readStylesXml({ - root: new XmlElement("w:styles", {}, [ - paragraphStyleElement("Heading1", null), - characterStyleElement("Heading1Char", null) - ]) - }); - assert.equal(styles.findParagraphStyleById("Heading1Char"), null); - assert.equal(styles.findCharacterStyleById("Heading1"), null); + var styles = readStylesXml({ + root: new XmlElement("w:styles", {}, [ + unusualStyleElement("paragraph", "Heading1", "Heading 1"), + unusualStyleElement("character", "Heading1Char", "Heading1Char 1") + ]) + }); + assert.equal(styles.findParagraphStyleById("Heading1").name, null); + assert.equal(styles.findCharacterStyleById("Heading1Char").name, null); }); + }); function paragraphStyleElement(id, name) { @@ -85,3 +86,9 @@ function styleElement(type, id, name) { new XmlElement("w:name", {"w:val": name}, []) ]); } + +function unusualStyleElement(type, id, name) { + return new XmlElement("w:style", {"w:type": type, "w:styleId": id}, [ + new XmlElement("w:notName", {"w:val": name}, []) + ]); +} -- cgit v1.2.3 From 499eb4cec34350f3e62c4e09ce3b791eb38b334d Mon Sep 17 00:00:00 2001 From: jaceyshome Date: Sat, 23 May 2015 12:33:25 +1000 Subject: rename the styles-reader.tests last case to 'style name is null if w:name element does not exist' --- tests/docx/styles-reader.tests.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/docx/styles-reader.tests.js b/tests/docx/styles-reader.tests.js index bd28673..0bbc8ff 100644 --- a/tests/docx/styles-reader.tests.js +++ b/tests/docx/styles-reader.tests.js @@ -60,11 +60,11 @@ describe('readStylesXml', function() { assert.equal(styles.findParagraphStyleById("Heading1").name, "Heading 1"); }); - test('styles names should be null by default', function() { + test('style name is null if w:name element does not exist', function() { var styles = readStylesXml({ root: new XmlElement("w:styles", {}, [ - unusualStyleElement("paragraph", "Heading1", "Heading 1"), - unusualStyleElement("character", "Heading1Char", "Heading1Char 1") + styleWithoutWNameElement("paragraph", "Heading1", "Heading 1"), + styleWithoutWNameElement("character", "Heading1Char", "Heading1Char 1") ]) }); assert.equal(styles.findParagraphStyleById("Heading1").name, null); @@ -87,7 +87,7 @@ function styleElement(type, id, name) { ]); } -function unusualStyleElement(type, id, name) { +function styleWithoutWNameElement(type, id, name) { return new XmlElement("w:style", {"w:type": type, "w:styleId": id}, [ new XmlElement("w:notName", {"w:val": name}, []) ]); -- cgit v1.2.3 From 60d6d9e584c44c3beae16110b6685a0a86bc38b4 Mon Sep 17 00:00:00 2001 From: jaceyshome Date: Sun, 24 May 2015 09:42:02 +1000 Subject: remove redundant code in styles-reader test case 'style name is null if w:name element does not exist' --- tests/docx/styles-reader.tests.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/docx/styles-reader.tests.js b/tests/docx/styles-reader.tests.js index 0bbc8ff..73a9050 100644 --- a/tests/docx/styles-reader.tests.js +++ b/tests/docx/styles-reader.tests.js @@ -63,8 +63,8 @@ describe('readStylesXml', function() { test('style name is null if w:name element does not exist', function() { var styles = readStylesXml({ root: new XmlElement("w:styles", {}, [ - styleWithoutWNameElement("paragraph", "Heading1", "Heading 1"), - styleWithoutWNameElement("character", "Heading1Char", "Heading1Char 1") + styleWithoutWNameElement("paragraph", "Heading1"), + styleWithoutWNameElement("character", "Heading1Char") ]) }); assert.equal(styles.findParagraphStyleById("Heading1").name, null); @@ -87,8 +87,6 @@ function styleElement(type, id, name) { ]); } -function styleWithoutWNameElement(type, id, name) { - return new XmlElement("w:style", {"w:type": type, "w:styleId": id}, [ - new XmlElement("w:notName", {"w:val": name}, []) - ]); +function styleWithoutWNameElement(type, id) { + return new XmlElement("w:style", {"w:type": type, "w:styleId": id}, []); } -- cgit v1.2.3