From 41cdf4345f9a64f66d6df12bb7d0a68c13370e8c Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 12 Sep 2015 13:36:21 +0100 Subject: Add content type for embedded style map --- tests/docx/style-map.tests.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tests') diff --git a/tests/docx/style-map.tests.js b/tests/docx/style-map.tests.js index fcf22ab..34dab8d 100644 --- a/tests/docx/style-map.tests.js +++ b/tests/docx/style-map.tests.js @@ -64,15 +64,49 @@ describe("style-map", function() { }); }); }); + + 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 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