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('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(); var 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); }); }); }); }); function normalDocx() { var zip = new JSZip(); var originalRelationshipsXml = '' + '' + '' + ''; zip.file("word/_rels/document.xml.rels", originalRelationshipsXml); var buffer = zip.generate({type: "arraybuffer"}); return zipfile.openArrayBuffer(buffer); }