<commit_before>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();
        
        return styleMap.writeStyleMap(zip, "p => h1").then(function() {
            return zip.read("word/_rels/document.xml.rels", "utf8").then(function(contents) {
                assert.equal(contents, expectedRelationshipsXml);
            });<commit_msg>Test that null is returned when trying to read non-existent style map<commit_after>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);
            });
{'fraction_non_alphanumeric': 0.15438247011952191, 'fraction_numerical': 0.004648074369189907, 'mean_word_length': 2.3815937149270483, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2860329', 'n_tokens_mistral': 844, 'n_tokens_neox': 817, 'n_words': 193}