aboutsummaryrefslogtreecommitdiff
path: root/tests/docx/styles-reader.tests.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-07-03 19:19:21 +0100
committerMichael Williamson <mike@zwobble.org>2016-07-03 19:20:00 +0100
commit0b56dfce42c3944cce47e284608e6806f4c839c3 (patch)
tree5f96f9c2908f1c5b00a7192e71d4c192abd7cf47 /tests/docx/styles-reader.tests.js
parent627c4a755395e313234bdb1914d168392006c483 (diff)
Move tests to test for easier Mocha usage
Diffstat (limited to 'tests/docx/styles-reader.tests.js')
-rw-r--r--tests/docx/styles-reader.tests.js92
1 files changed, 0 insertions, 92 deletions
diff --git a/tests/docx/styles-reader.tests.js b/tests/docx/styles-reader.tests.js
deleted file mode 100644
index 4ff19c7..0000000
--- a/tests/docx/styles-reader.tests.js
+++ /dev/null
@@ -1,92 +0,0 @@
-var assert = require("assert");
-
-var readStylesXml = require("../../lib/docx/styles-reader").readStylesXml;
-var XmlElement = require("../../lib/xml").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", {}, [
- paragraphStyleElement("Heading1", "Heading 1")
- ])
- });
- assert.equal(styles.findParagraphStyleById("Heading1").styleId, "Heading1");
- });
-
- test('character style can be found by ID', function() {
- var styles = readStylesXml({
- root: new XmlElement("w:styles", {}, [
- characterStyleElement("Heading1Char", "Heading 1 Char")
- ])
- });
- assert.equal(styles.findCharacterStyleById("Heading1Char").styleId, "Heading1Char");
- });
-
- test('paragraph and character styles are distinct', function() {
- var styles = readStylesXml({
- root: new XmlElement("w:styles", {}, [
- paragraphStyleElement("Heading1", "Heading 1"),
- characterStyleElement("Heading1Char", "Heading 1 Char")
- ])
- });
- assert.equal(styles.findCharacterStyleById("Heading1"), null);
- assert.equal(styles.findParagraphStyleById("Heading1Char"), null);
- });
-
- test('character and table styles are distinct', function() {
- var styles = readStylesXml({
- root: new XmlElement("w:styles", {}, [
- styleElement("table", "Heading1", "Heading 1")
- ])
- });
- assert.equal(styles.findCharacterStyleById("Heading1"), null);
- });
-
- test('styles include names', function() {
- var styles = readStylesXml({
- root: new XmlElement("w:styles", {}, [
- paragraphStyleElement("Heading1", "Heading 1")
- ])
- });
- assert.equal(styles.findParagraphStyleById("Heading1").name, "Heading 1");
- });
-
- test('style name is null if w:name element does not exist', function() {
- var styles = readStylesXml({
- root: new XmlElement("w:styles", {}, [
- styleWithoutWNameElement("paragraph", "Heading1"),
- styleWithoutWNameElement("character", "Heading1Char")
- ])
- });
- assert.equal(styles.findParagraphStyleById("Heading1").name, null);
- assert.equal(styles.findCharacterStyleById("Heading1Char").name, null);
- });
-
-});
-
-function paragraphStyleElement(id, name) {
- return styleElement("paragraph", id, name);
-}
-
-function characterStyleElement(id, name) {
- return styleElement("character", id, name);
-}
-
-function styleElement(type, id, name) {
- return new XmlElement("w:style", {"w:type": type, "w:styleId": id}, [
- new XmlElement("w:name", {"w:val": name}, [])
- ]);
-}
-
-function styleWithoutWNameElement(type, id) {
- return new XmlElement("w:style", {"w:type": type, "w:styleId": id}, []);
-}