summaryrefslogtreecommitdiffstats
path: root/test/assertions.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-03-24 11:54:03 +0100
committerSamy Pessé <samypesse@gmail.com>2015-03-24 11:54:03 +0100
commitafbca4bdf522f01e12cf61ec738c5c81fc05209b (patch)
treea8036419c8817e261f759a9fc0aab7511c1e071c /test/assertions.js
parentb61371942b0b29df418a1d7fda4fbec82afb534f (diff)
downloadgitbook-afbca4bdf522f01e12cf61ec738c5c81fc05209b.zip
gitbook-afbca4bdf522f01e12cf61ec738c5c81fc05209b.tar.gz
gitbook-afbca4bdf522f01e12cf61ec738c5c81fc05209b.tar.bz2
Improve tests for glossary
Diffstat (limited to 'test/assertions.js')
-rw-r--r--test/assertions.js33
1 files changed, 17 insertions, 16 deletions
diff --git a/test/assertions.js b/test/assertions.js
index 23feaf6..8bb440f 100644
--- a/test/assertions.js
+++ b/test/assertions.js
@@ -20,26 +20,27 @@ should.Assertion.add('jsonfile', function(file, description) {
this.assert(JSON.parse(fs.readFileSync(path.resolve(this.obj.options.output, file), { encoding: "utf-8" })));
});
-should.Assertion.add('html', function(query, validations, description) {
- validations = _.defaults(validations || {}, {
- count: 1,
- attributes: {}
- });
-
-
+should.Assertion.add('html', function(rules, description) {
this.params = { actual: "HTML string", operator: 'valid html', message: description };
-
var $ = cheerio.load(this.obj);
- var $el = $(query);
- // Test number of elements
- $el.should.have.lengthOf(validations.count);
+ _.each(rules, function(validations, query) {
+ validations = _.defaults(validations || {}, {
+ count: 1,
+ attributes: {}
+ });
+
+ var $el = $(query);
+
+ // Test number of elements
+ $el.should.have.lengthOf(validations.count);
- // Test text
- if (validations.text !== undefined) $el.text().should.be.equal(validations.text);
+ // Test text
+ if (validations.text !== undefined) $el.text().should.be.equal(validations.text);
- // Test attributes
- _.each(validations.attributes, function(value, name) {
- $el.attr(name).should.be.equal(value);
+ // Test attributes
+ _.each(validations.attributes, function(value, name) {
+ $el.attr(name).should.be.equal(value);
+ });
});
});