summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-02-14 22:49:55 +0100
committerSamy Pessé <samypesse@gmail.com>2016-02-14 22:49:55 +0100
commitfef822145d43d80dbbefa8712eab88ad7044d6c1 (patch)
tree611af2ef4292e9e9a918c2840db2a65b7efdd587 /test
parentcfefa7d57992738373649dab16cbaf4754c3e5c7 (diff)
downloadgitbook-fef822145d43d80dbbefa8712eab88ad7044d6c1.zip
gitbook-fef822145d43d80dbbefa8712eab88ad7044d6c1.tar.gz
gitbook-fef822145d43d80dbbefa8712eab88ad7044d6c1.tar.bz2
Move conrefs to a separate mixin
Diffstat (limited to 'test')
-rw-r--r--test/all.js1
-rw-r--r--test/conrefs.js49
-rw-r--r--test/page.js4
-rw-r--r--test/template.js49
4 files changed, 59 insertions, 44 deletions
diff --git a/test/all.js b/test/all.js
index 35957b4..2c87155 100644
--- a/test/all.js
+++ b/test/all.js
@@ -10,6 +10,7 @@ require('./parse');
require('./git');
require('./template');
+require('./conrefs');
// Output
require('./output-json');
diff --git a/test/conrefs.js b/test/conrefs.js
new file mode 100644
index 0000000..e75055c
--- /dev/null
+++ b/test/conrefs.js
@@ -0,0 +1,49 @@
+var mock = require('./mock');
+var ConrefsLoader = require('../lib/output/conrefs');
+
+
+describe('Conrefs Loader', function() {
+ var output;
+
+ before(function() {
+ return mock.outputDefaultBook(ConrefsLoader, {
+ 'test.md': 'World'
+ })
+ .then(function(_output) {
+ output = _output;
+ });
+ });
+
+
+ it('should include a local file', function() {
+ return output.template.renderString('Hello {% include "./test.md" %}')
+ .should.be.fulfilledWith('Hello World');
+ });
+
+ it('should include a git url', function() {
+ return output.template.renderString('Hello {% include "./test.md" %}')
+ .should.be.fulfilledWith('Hello World');
+ });
+
+ it('should reject file out of scope', function() {
+ return output.template.renderString('Hello {% include "../test.md" %}')
+ .should.be.rejected();
+ });
+
+ describe('Git Urls', function() {
+ it('should include a file from a git repo', function() {
+ return output.template.renderString('{% include "git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test.md" %}')
+ .should.be.fulfilledWith('Hello from git');
+ });
+
+ it('should handle deep inclusion (1)', function() {
+ return output.template.renderString('{% include "git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test2.md" %}')
+ .should.be.fulfilledWith('First Hello. Hello from git');
+ });
+
+ it('should handle deep inclusion (2)', function() {
+ return output.template.renderString('{% include "git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test3.md" %}')
+ .should.be.fulfilledWith('First Hello. Hello from git');
+ });
+ });
+});
diff --git a/test/page.js b/test/page.js
index d844d13..8dbfe8b 100644
--- a/test/page.js
+++ b/test/page.js
@@ -54,7 +54,7 @@ describe('Page', function() {
it('should add a default ID to headings', function() {
var page = book.addPage('heading.md');
- return page.parse(output)
+ return page.toHTML(output)
.then(function() {
page.content.should.be.html({
'h1#hello': {
@@ -73,7 +73,7 @@ describe('Page', function() {
before(function() {
page = book.addPage('links.md');
- return page.parse(output);
+ return page.toHTML(output);
});
it('should replace links to page to .html', function() {
diff --git a/test/template.js b/test/template.js
index f338a84..536043d 100644
--- a/test/template.js
+++ b/test/template.js
@@ -1,63 +1,28 @@
var mock = require('./mock');
var pkg = require('../package.json');
+var Output = require('../lib/output/base');
describe('Template', function() {
- var book;
+ var output;
before(function() {
- return mock.setupDefaultBook({
+ return mock.outputDefaultBook(Output, {
'test.md': 'World'
})
- .then(function(_book) {
- book = _book;
- return book.parse();
+ .then(function(_output) {
+ output = _output;
});
});
describe('.renderString', function() {
it('should render a simple string', function() {
- return book.template.renderString('Hello World')
+ return output.template.renderString('Hello World')
.should.be.fulfilledWith('Hello World');
});
it('should render with variable', function() {
- return book.template.renderString('Version is {{ gitbook.version }}')
+ return output.template.renderString('Version is {{ gitbook.version }}')
.should.be.fulfilledWith('Version is '+pkg.version);
});
});
-
- describe('Conrefs Loader', function() {
- it('should include a local file', function() {
- return book.template.renderString('Hello {% include "./test.md" %}')
- .should.be.fulfilledWith('Hello World');
- });
-
- it('should include a git url', function() {
- return book.template.renderString('Hello {% include "./test.md" %}')
- .should.be.fulfilledWith('Hello World');
- });
-
- it('should reject file out of scope', function() {
- return book.template.renderString('Hello {% include "../test.md" %}')
- .should.be.rejected();
- });
-
- describe('Git Urls', function() {
- it('should include a file from a git repo', function() {
- return book.template.renderString('{% include "git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test.md" %}')
- .should.be.fulfilledWith('Hello from git');
- });
-
- it('should handle deep inclusion (1)', function() {
- return book.template.renderString('{% include "git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test2.md" %}')
- .should.be.fulfilledWith('First Hello. Hello from git');
- });
-
- it('should handle deep inclusion (2)', function() {
- return book.template.renderString('{% include "git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test3.md" %}')
- .should.be.fulfilledWith('First Hello. Hello from git');
- });
- });
- });
-
});