diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-11-19 14:53:45 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-11-19 14:53:45 +0000 |
| commit | a7146d18d1183fbe0203025f5e0e6aee5cd3775c (patch) | |
| tree | 0742a812f4488265ca33ff7221bd97b78c500e53 /test/options-reader.tests.js | |
| parent | 599b3f17555a9d0c03ff040df6dca232b152a6f0 (diff) | |
Include embedded style map when explicit style map is set
Diffstat (limited to 'test/options-reader.tests.js')
| -rw-r--r-- | test/options-reader.tests.js | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/test/options-reader.tests.js b/test/options-reader.tests.js index b0f202b..bad4c56 100644 --- a/test/options-reader.tests.js +++ b/test/options-reader.tests.js @@ -1,5 +1,7 @@ var assert = require("assert"); +var _ = require("underscore"); + var optionsReader = require("../lib/options-reader"); var standardOptions = optionsReader._standardOptions; var readOptions = optionsReader.readOptions; @@ -7,42 +9,49 @@ var test = require("./test")(module); test('standard options are used if options is undefined', function() { - assert.deepEqual(standardOptions, readOptions(undefined)); + var options = readOptions(undefined); + assert.deepEqual(standardOptions, _.omit(options, "customStyleMap", "readStyleMap")); + assert.deepEqual(options.customStyleMap, []); }); test('standard options are used if options is empty', function() { - assert.deepEqual(standardOptions, readOptions({})); + var options = readOptions({}); + assert.deepEqual(standardOptions, _.omit(options, "customStyleMap", "readStyleMap")); + assert.deepEqual(options.customStyleMap, []); }); test('custom style map as string is prepended to standard style map', function() { var options = readOptions({ styleMap: "p.SectionTitle => h2" }); - assert.deepEqual("p.SectionTitle => h2", options.styleMap[0]); - assert.deepEqual(standardOptions.styleMap, options.styleMap.slice(1)); + var styleMap = options.readStyleMap(); + assert.deepEqual("p.SectionTitle => h2", styleMap[0]); + assert.deepEqual(optionsReader._defaultStyleMap, styleMap.slice(1)); }); test('custom style map as array is prepended to standard style map', function() { var options = readOptions({ styleMap: ["p.SectionTitle => h2"] }); - assert.deepEqual("p.SectionTitle => h2", options.styleMap[0]); - assert.deepEqual(standardOptions.styleMap, options.styleMap.slice(1)); + var styleMap = options.readStyleMap(); + assert.deepEqual("p.SectionTitle => h2", styleMap[0]); + assert.deepEqual(optionsReader._defaultStyleMap, styleMap.slice(1)); }); test('lines starting with # in custom style map are ignored', function() { var options = readOptions({ styleMap: "# p.SectionTitle => h3\np.SectionTitle => h2" }); - assert.deepEqual("p.SectionTitle => h2", options.styleMap[0]); - assert.deepEqual(standardOptions.styleMap, options.styleMap.slice(1)); + var styleMap = options.readStyleMap(); + assert.deepEqual("p.SectionTitle => h2", styleMap[0]); + assert.deepEqual(optionsReader._defaultStyleMap, styleMap.slice(1)); }); test('blank lines in custom style map are ignored', function() { var options = readOptions({ styleMap: "\n\n" }); - assert.deepEqual(standardOptions.styleMap, options.styleMap); + assert.deepEqual(optionsReader._defaultStyleMap, options.readStyleMap()); }); test('default style mappings are ignored if includeDefaultStyleMap is false', function() { @@ -50,5 +59,5 @@ test('default style mappings are ignored if includeDefaultStyleMap is false', fu styleMap: "p.SectionTitle => h2", includeDefaultStyleMap: false }); - assert.deepEqual(["p.SectionTitle => h2"], options.styleMap); + assert.deepEqual(["p.SectionTitle => h2"], options.readStyleMap()); }); |
