aboutsummaryrefslogtreecommitdiff
path: root/test/docx/style-map.tests.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-07-07 22:17:34 +0100
committerMichael Williamson <mike@zwobble.org>2016-07-07 22:17:34 +0100
commita080fc59a3fca08bdc6e23a2eeae440f5c7047b3 (patch)
tree3d56033c294c617eb7de6b693750efb70a81dd4f /test/docx/style-map.tests.js
parent28a0e40b645c051d91626ca90959e847b061c8da (diff)
Use exports for all tests
Diffstat (limited to 'test/docx/style-map.tests.js')
-rw-r--r--test/docx/style-map.tests.js115
1 files changed, 56 insertions, 59 deletions
diff --git a/test/docx/style-map.tests.js b/test/docx/style-map.tests.js
index 55171f8..4ddb127 100644
--- a/test/docx/style-map.tests.js
+++ b/test/docx/style-map.tests.js
@@ -4,85 +4,82 @@ var JSZip = require("jszip");
var zipfile = require("../../lib/zipfile");
var styleMap = require("../../lib/docx/style-map");
-var test = require("../testing").test;
+var test = require("../test")(module);
-describe("style-map", function() {
- test('reading embedded style map on document without embedded style map returns null', function() {
- var zip = normalDocx();
-
- return styleMap.readStyleMap(zip).then(function(contents) {
- assert.equal(contents, null);
- });
+test('reading embedded style map on document without embedded style map returns null', function() {
+ var zip = normalDocx();
+
+ return styleMap.readStyleMap(zip).then(function(contents) {
+ assert.equal(contents, null);
});
+});
+
+test('embedded style map can be read after being written', function() {
+ var zip = normalDocx();
- test('embedded style map can be read after being written', function() {
- var zip = normalDocx();
-
- return styleMap.writeStyleMap(zip, "p => h1").then(function() {
- return styleMap.readStyleMap(zip).then(function(contents) {
- assert.equal(contents, "p => h1");
- });
+ return styleMap.writeStyleMap(zip, "p => h1").then(function() {
+ return styleMap.readStyleMap(zip).then(function(contents) {
+ assert.equal(contents, "p => h1");
});
});
+});
+
+test('embedded style map is written to separate file', function() {
+ var zip = normalDocx();
- test('embedded style map is written to separate file', function() {
- var zip = normalDocx();
-
- return styleMap.writeStyleMap(zip, "p => h1").then(function() {
- return zip.read("mammoth/style-map", "utf8").then(function(contents) {
- assert.equal(contents, "p => h1");
- });
+ return styleMap.writeStyleMap(zip, "p => h1").then(function() {
+ return zip.read("mammoth/style-map", "utf8").then(function(contents) {
+ assert.equal(contents, "p => h1");
});
});
+});
+
+test('embedded style map is referenced in relationships', function() {
+ var zip = normalDocx();
- test('embedded style map is referenced in relationships', function() {
- var zip = normalDocx();
-
- return styleMap.writeStyleMap(zip, "p => h1").then(function() {
- return zip.read("word/_rels/document.xml.rels", "utf8").then(function(contents) {
- assert.equal(contents, expectedRelationshipsXml);
- });
+ return styleMap.writeStyleMap(zip, "p => h1").then(function() {
+ return zip.read("word/_rels/document.xml.rels", "utf8").then(function(contents) {
+ assert.equal(contents, expectedRelationshipsXml);
});
});
+});
+
+test('re-embedding style map replaces original', function() {
+ var zip = normalDocx();
- test('re-embedding style map replaces original', function() {
- var zip = normalDocx();
-
- return styleMap.writeStyleMap(zip, "p => h1").then(function() {
- return styleMap.writeStyleMap(zip, "p => h2");
- }).then(function() {
- return zip.read("word/_rels/document.xml.rels", "utf8").then(function(contents) {
- assert.equal(contents, expectedRelationshipsXml);
- });
- }).then(function() {
- return styleMap.readStyleMap(zip).then(function(contents) {
- assert.equal(contents, "p => h2");
- });
+ return styleMap.writeStyleMap(zip, "p => h1").then(function() {
+ return styleMap.writeStyleMap(zip, "p => h2");
+ }).then(function() {
+ return zip.read("word/_rels/document.xml.rels", "utf8").then(function(contents) {
+ assert.equal(contents, expectedRelationshipsXml);
+ });
+ }).then(function() {
+ return styleMap.readStyleMap(zip).then(function(contents) {
+ assert.equal(contents, "p => h2");
});
});
+});
+
+test('embedded style map has override content type in [Content_Types].xml', function() {
+ var zip = normalDocx();
- test('embedded style map has override content type in [Content_Types].xml', function() {
- var zip = normalDocx();
-
- return styleMap.writeStyleMap(zip, "p => h1").then(function() {
- return zip.read("[Content_Types].xml", "utf8").then(function(contents) {
- assert.equal(contents, expectedContentTypesXml);
- });
+ return styleMap.writeStyleMap(zip, "p => h1").then(function() {
+ return zip.read("[Content_Types].xml", "utf8").then(function(contents) {
+ assert.equal(contents, expectedContentTypesXml);
});
});
+});
+
+test('replacing style map keeps content type', function() {
+ var zip = normalDocx();
- test('replacing style map keeps content type', function() {
- var zip = normalDocx();
-
- return styleMap.writeStyleMap(zip, "p => h1").then(function() {
- return styleMap.writeStyleMap(zip, "p => h2");
- }).then(function() {
- return zip.read("[Content_Types].xml", "utf8").then(function(contents) {
- assert.equal(contents, expectedContentTypesXml);
- });
+ return styleMap.writeStyleMap(zip, "p => h1").then(function() {
+ return styleMap.writeStyleMap(zip, "p => h2");
+ }).then(function() {
+ return zip.read("[Content_Types].xml", "utf8").then(function(contents) {
+ assert.equal(contents, expectedContentTypesXml);
});
});
-
});
var expectedRelationshipsXml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' +