diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-11-19 12:11:22 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-11-19 12:11:22 +0000 |
| commit | f3676789408dfaf898823c1fbe3cb7d6888a1fd4 (patch) | |
| tree | 5129ae6ac59ae7349f64f35bb05c24d79e4c6a34 /test | |
| parent | 6bef85a8fde03b50de4aa78064ab4c32ad54041c (diff) | |
Add startsWith style name matcher
Diffstat (limited to 'test')
| -rw-r--r-- | test/styles/document-matchers.tests.js | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/test/styles/document-matchers.tests.js b/test/styles/document-matchers.tests.js index 9f2864b..fb2025d 100644 --- a/test/styles/document-matchers.tests.js +++ b/test/styles/document-matchers.tests.js @@ -25,13 +25,6 @@ test("paragraph style name only matches paragraphs with that style name", functi assert.ok(!matcher.matches(paragraphWithStyle("Heading2", "Heading 2"))); }); -test("paragraph style name matching is case insensitive", function() { - var matcher = documentMatchers.paragraph({styleName: documentMatchers.equalTo("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())); @@ -55,3 +48,23 @@ test("matchers for lists with index 0 do not match elements that are not lists", function paragraphWithStyle(styleId, styleName) { return new Paragraph([], {styleId: styleId, styleName: styleName}); } + + +test("equalTo matcher is case insensitive", function() { + var matcher = documentMatchers.equalTo("Heading 1"); + assert.ok(matcher.operator(matcher.operand, "heaDING 1")); + assert.ok(!matcher.operator(matcher.operand, "heaDING 2")); +}); + +test("startsWith matches strings with prefix", function() { + var matcher = documentMatchers.startsWith("Heading"); + assert.ok(matcher.operator(matcher.operand, "Heading 1")); + assert.ok(!matcher.operator(matcher.operand, "Custom Heading")); + assert.ok(!matcher.operator(matcher.operand, "Head")); + assert.ok(!matcher.operator(matcher.operand, "Header 2")); +}); + +test("startsWith matcher is case insensitive", function() { + var matcher = documentMatchers.startsWith("Heading"); + assert.ok(matcher.operator(matcher.operand, "heaDING")); +}); |
