From cdf71ffdfa56ed698513b8a1d424c73967816c38 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 4 May 2013 10:31:45 +0100 Subject: Add tests for document-matchers --- tests/document-matchers.tests.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/document-matchers.tests.js (limited to 'tests') diff --git a/tests/document-matchers.tests.js b/tests/document-matchers.tests.js new file mode 100644 index 0000000..55fd447 --- /dev/null +++ b/tests/document-matchers.tests.js @@ -0,0 +1,25 @@ +var assert = require("assert"); + +var test = require("./testing").test; +var documentMatchers = require("../lib/document-matchers"); +var documents = require("../lib/documents"); + + +describe("document-matchers", function() { + test("paragraph with no style name matches any paragraph", function() { + var matcher = documentMatchers.paragraph(); + assert.ok(matcher.matches(new documents.Paragraph())); + assert.ok(matcher.matches(new paragraphWithStyle("Heading1"))); + }); + + test("paragraph style name only matches paragraphs with that style", function() { + var matcher = documentMatchers.paragraph("Heading1"); + assert.ok(!matcher.matches(new documents.Paragraph())); + assert.ok(matcher.matches(paragraphWithStyle("Heading1"))); + assert.ok(!matcher.matches(paragraphWithStyle("Heading2"))); + }); +}); + +function paragraphWithStyle(styleName) { + return new documents.Paragraph([], {styleName: styleName}); +} -- cgit v1.2.3