Add tests for conrefs

This commit is contained in:
Samy Pessé
2015-03-24 18:22:44 +01:00
parent b2e684af8f
commit 48ab44a776
5 changed files with 63 additions and 2 deletions
+8 -2
View File
@@ -27,7 +27,9 @@ should.Assertion.add('html', function(rules, description) {
_.each(rules, function(validations, query) {
validations = _.defaults(validations || {}, {
count: 1,
attributes: {}
attributes: {},
trim: false,
text: undefined
});
var $el = $(query);
@@ -36,7 +38,11 @@ should.Assertion.add('html', function(rules, description) {
$el.should.have.lengthOf(validations.count);
// Test text
if (validations.text !== undefined) $el.text().should.be.equal(validations.text);
if (validations.text !== undefined) {
var text = $el.text();
if (validations.trim) text = text.trim();
text.should.be.equal(validations.text);
}
// Test attributes
_.each(validations.attributes, function(value, name) {
+10
View File
@@ -0,0 +1,10 @@
# Readme
### Relative
<p id="t1">{% include "./hello.md" %}</p>
### Git
<p id="t2">{% include "git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test.md" %}</p>
<p id="t3">{% include "git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test2.md" %}</p>
+1
View File
@@ -0,0 +1 @@
# Summary
+1
View File
@@ -0,0 +1 @@
Hello World
+43
View File
@@ -0,0 +1,43 @@
var fs = require('fs');
var path = require('path');
describe('ConRefs', function () {
var book, readme;
before(function() {
return books.generate("conrefs", "website")
.then(function(_book) {
book = _book;
readme = fs.readFileSync(
path.join(book.options.output, "index.html"),
{ encoding: "utf-8" }
);
});
});
it('should handle local references', function() {
readme.should.be.html({
".page-inner p#t1": {
count: 1,
text: "Hello World",
trim: true
}
});
});
it('should handle git references', function() {
readme.should.be.html({
".page-inner p#t2": {
count: 1,
text: "Hello from git",
trim: true
},
".page-inner p#t3": {
count: 1,
text: "First Hello. Hello from git",
trim: true
}
});
});
});