aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2014-04-22 11:25:58 +0100
committerMichael Williamson <mike@zwobble.org>2014-04-22 11:25:58 +0100
commit7cad7ca1dcdf48ac826c54e33629bb961c7380dd (patch)
treed0b4005d2f05f7fe74d3cc9abd380100de615a6c /tests
parentea1c98fb4fc0aee93c194e6a90cf9b71326705af (diff)
Read styles from styles.xml
Diffstat (limited to 'tests')
-rw-r--r--tests/docx/styles-reader.tests.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/docx/styles-reader.tests.js b/tests/docx/styles-reader.tests.js
new file mode 100644
index 0000000..dd82602
--- /dev/null
+++ b/tests/docx/styles-reader.tests.js
@@ -0,0 +1,28 @@
+var assert = require("assert");
+
+var duck = require("duck");
+
+var readStylesXml = require("../../lib/docx/styles-reader").readStylesXml;
+var XmlElement = require("../../lib/xmlreader").Element;
+var test = require("../testing").test;
+
+
+describe('readStylesXml', function() {
+ test('paragraph style is null if no style with that ID exists', function() {
+ var styles = readStylesXml({
+ root: new XmlElement("w:styles", {}, [])
+ });
+ assert.equal(styles.findParagraphStyleById("Heading1"), null);
+ });
+
+ test('paragraph style can be found by ID', function() {
+ var styles = readStylesXml({
+ root: new XmlElement("w:styles", {}, [
+ new XmlElement("w:style", {"w:styleId": "Heading1"}, [
+ new XmlElement("w:name", {"w:val": "Heading 1"}, [])
+ ])
+ ])
+ });
+ assert.equal(styles.findParagraphStyleById("Heading1").styleId, "Heading1");
+ });
+});