aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2014-04-22 13:41:52 +0100
committerMichael Williamson <mike@zwobble.org>2014-04-22 13:41:52 +0100
commit86d2aaed235cd354884d7e71ec4543f4c97e2c8b (patch)
tree02eb94567b79a9736bc69c2749362045892b667c
parentec837dc5c639efa92fb676dc90c008ad7cfff58e (diff)
Always create paragraph matcher with options object
-rw-r--r--lib/document-matchers.js4
-rw-r--r--tests/document-matchers.tests.js14
-rw-r--r--tests/style-reader.tests.js2
3 files changed, 8 insertions, 12 deletions
diff --git a/lib/document-matchers.js b/lib/document-matchers.js
index 0846513..8ed5e80 100644
--- a/lib/document-matchers.js
+++ b/lib/document-matchers.js
@@ -6,10 +6,6 @@ exports.run = run;
function paragraph(options) {
options = options || {};
- if (_.isString(options)) {
- // TODO: this is deprecated, remove usages
- options = {styleId: options};
- }
return new Matcher("paragraph", options);
}
diff --git a/tests/document-matchers.tests.js b/tests/document-matchers.tests.js
index 581746c..070e0bf 100644
--- a/tests/document-matchers.tests.js
+++ b/tests/document-matchers.tests.js
@@ -6,17 +6,17 @@ var documents = require("../lib/documents");
var Paragraph = documents.Paragraph;
describe("document-matchers", function() {
- test("paragraph with no style name matches any paragraph", 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")));
+ assert.ok(matcher.matches(paragraphWithStyleId("Heading1")));
});
- test("paragraph style name only matches paragraphs with that style", function() {
- var matcher = documentMatchers.paragraph("Heading1");
+ 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")));
- assert.ok(!matcher.matches(paragraphWithStyle("Heading2")));
+ assert.ok(matcher.matches(paragraphWithStyleId("Heading1")));
+ assert.ok(!matcher.matches(paragraphWithStyleId("Heading2")));
});
test("ordered-list(index) matches an ordered list with specified level index", function() {
@@ -40,6 +40,6 @@ describe("document-matchers", function() {
});
});
-function paragraphWithStyle(styleId) {
+function paragraphWithStyleId(styleId) {
return new Paragraph([], {styleId: styleId});
}
diff --git a/tests/style-reader.tests.js b/tests/style-reader.tests.js
index 7fff059..50986e5 100644
--- a/tests/style-reader.tests.js
+++ b/tests/style-reader.tests.js
@@ -58,7 +58,7 @@ describe("styleReader.readDocumentMatcher", function() {
test("reads paragraph with style ID", function() {
assert.deepEqual(
readDocumentMatcher("p.Heading1"),
- documentMatchers.paragraph("Heading1")
+ documentMatchers.paragraph({styleId: "Heading1"})
);
});