aboutsummaryrefslogtreecommitdiff
path: root/test/options-reader.tests.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-07-03 19:19:21 +0100
committerMichael Williamson <mike@zwobble.org>2016-07-03 19:20:00 +0100
commit0b56dfce42c3944cce47e284608e6806f4c839c3 (patch)
tree5f96f9c2908f1c5b00a7192e71d4c192abd7cf47 /test/options-reader.tests.js
parent627c4a755395e313234bdb1914d168392006c483 (diff)
Move tests to test for easier Mocha usage
Diffstat (limited to 'test/options-reader.tests.js')
-rw-r--r--test/options-reader.tests.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/options-reader.tests.js b/test/options-reader.tests.js
new file mode 100644
index 0000000..94c864c
--- /dev/null
+++ b/test/options-reader.tests.js
@@ -0,0 +1,48 @@
+var assert = require("assert");
+
+var optionsReader = require("../lib/options-reader");
+var standardOptions = optionsReader._standardOptions;
+var readOptions = optionsReader.readOptions;
+
+
+describe('readOptions', function() {
+ it('standard options are used if options is undefined', function() {
+ assert.deepEqual(standardOptions, readOptions(undefined));
+ });
+
+ it('standard options are used if options is empty', function() {
+ assert.deepEqual(standardOptions, readOptions({}));
+ });
+
+ it('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));
+ });
+
+ it('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));
+ });
+
+ it('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));
+ });
+
+ it('default style mappings are ignored if includeDefaultStyleMap is false', function() {
+ var options = readOptions({
+ styleMap: "p.SectionTitle => h2",
+ includeDefaultStyleMap: false
+ });
+ assert.deepEqual(["p.SectionTitle => h2"], options.styleMap);
+ });
+});