From 0b56dfce42c3944cce47e284608e6806f4c839c3 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 3 Jul 2016 19:19:21 +0100 Subject: Move tests to test for easier Mocha usage --- tests/docx/style-map.tests.js | 115 ------------------------------------------ 1 file changed, 115 deletions(-) delete mode 100644 tests/docx/style-map.tests.js (limited to 'tests/docx/style-map.tests.js') diff --git a/tests/docx/style-map.tests.js b/tests/docx/style-map.tests.js deleted file mode 100644 index 55171f8..0000000 --- a/tests/docx/style-map.tests.js +++ /dev/null @@ -1,115 +0,0 @@ -var assert = require("assert"); - -var JSZip = require("jszip"); - -var zipfile = require("../../lib/zipfile"); -var styleMap = require("../../lib/docx/style-map"); -var test = require("../testing").test; - -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('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"); - }); - }); - }); - - 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"); - }); - }); - }); - - 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); - }); - }); - }); - - 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"); - }); - }); - }); - - 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); - }); - }); - }); - - 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); - }); - }); - }); - -}); - -var expectedRelationshipsXml = '' + - '' + - '' + - '' + - ''; - -var expectedContentTypesXml = '' + - '' + - '' + - '' + - ''; - -function normalDocx() { - var zip = new JSZip(); - var originalRelationshipsXml = '' + - '' + - '' + - ''; - var originalContentTypesXml = '' + - '' + - '' + - ''; - zip.file("word/_rels/document.xml.rels", originalRelationshipsXml); - zip.file("[Content_Types].xml", originalContentTypesXml); - var buffer = zip.generate({type: "arraybuffer"}); - return zipfile.openArrayBuffer(buffer); -} - -- cgit v1.2.3