summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/assertions.js10
-rw-r--r--test/books/conrefs/README.md10
-rw-r--r--test/books/conrefs/SUMMARY.md1
-rw-r--r--test/books/conrefs/hello.md1
-rw-r--r--test/conrefs.js43
5 files changed, 63 insertions, 2 deletions
diff --git a/test/assertions.js b/test/assertions.js
index 83465e1..443929a 100644
--- a/test/assertions.js
+++ b/test/assertions.js
@@ -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) {
diff --git a/test/books/conrefs/README.md b/test/books/conrefs/README.md
new file mode 100644
index 0000000..7f56eed
--- /dev/null
+++ b/test/books/conrefs/README.md
@@ -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>
diff --git a/test/books/conrefs/SUMMARY.md b/test/books/conrefs/SUMMARY.md
new file mode 100644
index 0000000..ac9323c
--- /dev/null
+++ b/test/books/conrefs/SUMMARY.md
@@ -0,0 +1 @@
+# Summary
diff --git a/test/books/conrefs/hello.md b/test/books/conrefs/hello.md
new file mode 100644
index 0000000..557db03
--- /dev/null
+++ b/test/books/conrefs/hello.md
@@ -0,0 +1 @@
+Hello World
diff --git a/test/conrefs.js b/test/conrefs.js
new file mode 100644
index 0000000..8d6a181
--- /dev/null
+++ b/test/conrefs.js
@@ -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
+ }
+ });
+ });
+});