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/document-matchers.tests.js | |
| parent | 7dba15069f9a606b9e248d7e4cd024ddaa6ac3e3 (diff) | |
| parent | c42714e5f4b643de27b106a084601e39b7e5d04c (diff) | |
Merge branch 'master' into image-errors
Conflicts:
test/mammoth.tests.js
Diffstat (limited to 'test/document-matchers.tests.js')
| -rw-r--r-- | test/document-matchers.tests.js | 80 |
1 files changed, 39 insertions, 41 deletions
diff --git a/test/document-matchers.tests.js b/test/document-matchers.tests.js index 58dbf80..b989b2d 100644 --- a/test/document-matchers.tests.js +++ b/test/document-matchers.tests.js @@ -1,50 +1,48 @@ var assert = require("assert"); -var test = require("./testing").test; +var test = require("./test")(module); var documentMatchers = require("../lib/document-matchers"); var documents = require("../lib/documents"); var Paragraph = documents.Paragraph; -describe("document-matchers", function() { - test("paragraph with no options matches any paragraph", function() { - var matcher = documentMatchers.paragraph(); - assert.ok(matcher.matches(new Paragraph())); - assert.ok(matcher.matches(paragraphWithStyle("Heading1", "Heading 1"))); - }); - - test("paragraph style ID only matches paragraphs with that style ID", function() { - var matcher = documentMatchers.paragraph({styleId: "Heading1"}); - assert.ok(!matcher.matches(new Paragraph())); - assert.ok(matcher.matches(paragraphWithStyle("Heading1", "Heading 1"))); - assert.ok(!matcher.matches(paragraphWithStyle("Heading2", "Heading 2"))); - }); - - test("paragraph style name only matches paragraphs with that style name", function() { - var matcher = documentMatchers.paragraph({styleName: "Heading 1"}); - assert.ok(!matcher.matches(new Paragraph())); - assert.ok(matcher.matches(paragraphWithStyle("Heading1", "Heading 1"))); - assert.ok(!matcher.matches(paragraphWithStyle("Heading2", "Heading 2"))); - }); - - test("ordered-list(index) matches an ordered list with specified level index", function() { - var matcher = documentMatchers.paragraph({list: {isOrdered: true, levelIndex: 1}}); - assert.ok(!matcher.matches(new Paragraph())); - assert.ok(matcher.matches(new Paragraph([], {numbering: {level: 1, isOrdered: true}}))); - assert.ok(!matcher.matches(new Paragraph([], {numbering: {level: 0, isOrdered: true}}))); - assert.ok(!matcher.matches(new Paragraph([], {numbering: {level: 1, isOrdered: false}}))); - }); - - test("unordered-list(index) matches an unordered list with specified level index", function() { - var matcher = documentMatchers.paragraph({list: {isOrdered: false, levelIndex: 1}}); - assert.ok(!matcher.matches(new Paragraph())); - assert.ok(matcher.matches(new Paragraph([], {numbering: {level: 1, isOrdered: false}}))); - assert.ok(!matcher.matches(new Paragraph([], {numbering: {level: 1, isOrdered: true}}))); - }); - - test("matchers for lists with index 0 do not match elements that are not lists", function() { - var matcher = documentMatchers.paragraph({list: {isOrdered: true, levelIndex: 0}}); - assert.ok(!matcher.matches(new Paragraph())); - }); +test("paragraph with no options matches any paragraph", function() { + var matcher = documentMatchers.paragraph(); + assert.ok(matcher.matches(new Paragraph())); + assert.ok(matcher.matches(paragraphWithStyle("Heading1", "Heading 1"))); +}); + +test("paragraph style ID only matches paragraphs with that style ID", function() { + var matcher = documentMatchers.paragraph({styleId: "Heading1"}); + assert.ok(!matcher.matches(new Paragraph())); + assert.ok(matcher.matches(paragraphWithStyle("Heading1", "Heading 1"))); + assert.ok(!matcher.matches(paragraphWithStyle("Heading2", "Heading 2"))); +}); + +test("paragraph style name only matches paragraphs with that style name", function() { + var matcher = documentMatchers.paragraph({styleName: "Heading 1"}); + assert.ok(!matcher.matches(new Paragraph())); + assert.ok(matcher.matches(paragraphWithStyle("Heading1", "Heading 1"))); + assert.ok(!matcher.matches(paragraphWithStyle("Heading2", "Heading 2"))); +}); + +test("ordered-list(index) matches an ordered list with specified level index", function() { + var matcher = documentMatchers.paragraph({list: {isOrdered: true, levelIndex: 1}}); + assert.ok(!matcher.matches(new Paragraph())); + assert.ok(matcher.matches(new Paragraph([], {numbering: {level: 1, isOrdered: true}}))); + assert.ok(!matcher.matches(new Paragraph([], {numbering: {level: 0, isOrdered: true}}))); + assert.ok(!matcher.matches(new Paragraph([], {numbering: {level: 1, isOrdered: false}}))); +}); + +test("unordered-list(index) matches an unordered list with specified level index", function() { + var matcher = documentMatchers.paragraph({list: {isOrdered: false, levelIndex: 1}}); + assert.ok(!matcher.matches(new Paragraph())); + assert.ok(matcher.matches(new Paragraph([], {numbering: {level: 1, isOrdered: false}}))); + assert.ok(!matcher.matches(new Paragraph([], {numbering: {level: 1, isOrdered: true}}))); +}); + +test("matchers for lists with index 0 do not match elements that are not lists", function() { + var matcher = documentMatchers.paragraph({list: {isOrdered: true, levelIndex: 0}}); + assert.ok(!matcher.matches(new Paragraph())); }); function paragraphWithStyle(styleId, styleName) { |
