diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-09-12 13:36:21 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-09-12 13:43:30 +0100 |
| commit | 41cdf4345f9a64f66d6df12bb7d0a68c13370e8c (patch) | |
| tree | fb4f5d13ae49406476c8393ab7bb89e7a21d8b39 /tests | |
| parent | a84aa5097c5497799138dc0bdacd48dee4401ae2 (diff) | |
Add content type for embedded style map
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/docx/style-map.tests.js | 34 |
1 files changed, 34 insertions, 0 deletions
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 = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' + + '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">' + + '<Default Extension="png" ContentType="image/png"/>' + + '<Override PartName="/mammoth/style-map" ContentType="text/prs.mammoth.style-map"/>' + + '</Types>'; + function normalDocx() { var zip = new JSZip(); var originalRelationshipsXml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' + '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">' + '<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" Target="settings.xml"/>' + '</Relationships>'; + var originalContentTypesXml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' + + '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">' + + '<Default Extension="png" ContentType="image/png"/>' + + '</Types>'; zip.file("word/_rels/document.xml.rels", originalRelationshipsXml); + zip.file("[Content_Types].xml", originalContentTypesXml); var buffer = zip.generate({type: "arraybuffer"}); return zipfile.openArrayBuffer(buffer); } |
