diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-08-28 19:55:24 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-08-28 19:55:38 +0100 |
| commit | b1ae23f544c479d2b71347bbf67df7baac40d78f (patch) | |
| tree | 383e694dae42ba544f690c3b0ab388a7931c0793 /test/style-reader.tests.js | |
| parent | 7dba15069f9a606b9e248d7e4cd024ddaa6ac3e3 (diff) | |
| parent | c42714e5f4b643de27b106a084601e39b7e5d04c (diff) | |
Merge branch 'master' into image-errors
Conflicts:
test/mammoth.tests.js
Diffstat (limited to 'test/style-reader.tests.js')
| -rw-r--r-- | test/style-reader.tests.js | 108 |
1 files changed, 56 insertions, 52 deletions
diff --git a/test/style-reader.tests.js b/test/style-reader.tests.js index 7265e8f..19f9c00 100644 --- a/test/style-reader.tests.js +++ b/test/style-reader.tests.js @@ -3,7 +3,7 @@ var htmlPaths = require("../lib/html-paths"); var documentMatchers = require("../lib/document-matchers"); var styleReader = require("../lib/style-reader"); var results = require("../lib/results"); -var test = require("./testing").test; +var test = require("./test")(module); var readHtmlPath = styleReader.readHtmlPath; @@ -11,136 +11,140 @@ var readDocumentMatcher = styleReader.readDocumentMatcher; var readStyle = styleReader.readStyle; -describe('styleReader.readHtmlPath', function() { - test('reads empty path', function() { +test('styleReader.readHtmlPath', { + 'reads empty path': function() { assertHtmlPath("", htmlPaths.empty); - }); + }, - test('reads single element', function() { + 'reads single element': function() { assertHtmlPath("p", htmlPaths.elements(["p"])); - }); + }, - test('reads choice of elements', function() { + 'reads choice of elements': function() { assertHtmlPath( "ul|ol", htmlPaths.elements([ htmlPaths.element(["ul", "ol"]) ]) ); - }); + }, - test('reads nested elements', function() { + 'reads nested elements': function() { assertHtmlPath("ul > li", htmlPaths.elements(["ul", "li"])); - }); + }, - test('reads class on element', function() { + 'reads class on element': function() { var expected = htmlPaths.elements([ htmlPaths.element("p", {"class": "tip"}) ]); assertHtmlPath("p.tip", expected); - }); + }, - test('reads multiple classes on element', function() { + 'reads multiple classes on element': function() { var expected = htmlPaths.elements([ htmlPaths.element("p", {"class": "tip help"}) ]); assertHtmlPath("p.tip.help", expected); - }); + }, - test('reads when element must be fresh', function() { + 'reads when element must be fresh': function() { var expected = htmlPaths.elements([ htmlPaths.element("p", {}, {"fresh": true}) ]); assertHtmlPath("p:fresh", expected); - }); + }, - function assertHtmlPath(input, expected) { - assert.deepEqual(readHtmlPath(input), results.success(expected)); + 'reads ignore element': function() { + assertHtmlPath("!", htmlPaths.ignore); } }); -describe("styleReader.readDocumentMatcher", function() { - test("reads plain paragraph", function() { +function assertHtmlPath(input, expected) { + assert.deepEqual(readHtmlPath(input), results.success(expected)); +} + +test("styleReader.readDocumentMatcher", { + "reads plain paragraph": function() { assertDocumentMatcher("p", documentMatchers.paragraph()); - }); + }, - test("reads paragraph with style ID", function() { + "reads paragraph with style ID": function() { assertDocumentMatcher( "p.Heading1", documentMatchers.paragraph({styleId: "Heading1"}) ); - }); + }, - test("reads paragraph with style name", function() { + "reads paragraph with style name": function() { assertDocumentMatcher( "p[style-name='Heading 1']", documentMatchers.paragraph({styleName: "Heading 1"}) ); - }); + }, - test("reads p:ordered-list(1) as ordered list with index of 0", function() { + "reads p:ordered-list(1) as ordered list with index of 0": function() { assertDocumentMatcher( "p:ordered-list(1)", documentMatchers.paragraph({list: {isOrdered: true, levelIndex: 0}}) ); - }); + }, - test("reads p:unordered-list(1) as unordered list with index of 0", function() { + "reads p:unordered-list(1) as unordered list with index of 0": function() { assertDocumentMatcher( "p:unordered-list(1)", documentMatchers.paragraph({list: {isOrdered: false, levelIndex: 0}}) ); - }); + }, - test("reads plain run", function() { + "reads plain run": function() { assertDocumentMatcher( "r", documentMatchers.run() ); - }); + }, - test("reads bold", function() { + "reads bold": function() { assertDocumentMatcher( "b", documentMatchers.bold ); - }); + }, - test("reads italic", function() { + "reads italic": function() { assertDocumentMatcher( "i", documentMatchers.italic ); - }); + }, - test("reads underline", function() { + "reads underline": function() { assertDocumentMatcher( "u", documentMatchers.underline ); - }); + }, - test("reads strikethrough", function() { + "reads strikethrough": function() { assertDocumentMatcher( "strike", documentMatchers.strikethrough ); - }); + }, - test("reads comment-reference", function() { + "reads comment-reference": function() { assertDocumentMatcher( "comment-reference", documentMatchers.commentReference ); - }); - - function assertDocumentMatcher(input, expected) { - assert.deepEqual(readDocumentMatcher(input), results.success(expected)); } }); + +function assertDocumentMatcher(input, expected) { + assert.deepEqual(readDocumentMatcher(input), results.success(expected)); +} -describe("styleReader.read", function() { - test("document matcher is mapped to HTML path using arrow", function() { +test("styleReader.read", { + "document matcher is mapped to HTML path using arrow": function() { assertStyleMapping( "p => h1", { @@ -148,9 +152,9 @@ describe("styleReader.read", function() { to: htmlPaths.elements(["h1"]) } ); - }); + }, - test("reads style mapping with no HTML path", function() { + "reads style mapping with no HTML path": function() { assertStyleMapping( "r =>", { @@ -158,9 +162,9 @@ describe("styleReader.read", function() { to: htmlPaths.empty } ); - }); - - function assertStyleMapping(input, expected) { - assert.deepEqual(readStyle(input), results.success(expected)); } }); + +function assertStyleMapping(input, expected) { + assert.deepEqual(readStyle(input), results.success(expected)); +} |
