diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-12-22 10:18:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-22 10:18:38 +0100 |
commit | 194ebc3da9641ff96f083f9d8ab43c2d27944f9a (patch) | |
tree | c50988f32ccf18df93ae7ab40be78e9459642818 /lib/templating/__tests__/conrefsLoader.js | |
parent | 64ccb6b00b4b63fa0e516d4e35351275b34f8c07 (diff) | |
parent | 16af264360e48e8a833e9efa9ab8d194574dbc70 (diff) | |
download | gitbook-194ebc3da9641ff96f083f9d8ab43c2d27944f9a.zip gitbook-194ebc3da9641ff96f083f9d8ab43c2d27944f9a.tar.gz gitbook-194ebc3da9641ff96f083f9d8ab43c2d27944f9a.tar.bz2 |
Merge pull request #1543 from GitbookIO/dream
React for rendering website with plugins
Diffstat (limited to 'lib/templating/__tests__/conrefsLoader.js')
-rw-r--r-- | lib/templating/__tests__/conrefsLoader.js | 98 |
1 files changed, 0 insertions, 98 deletions
diff --git a/lib/templating/__tests__/conrefsLoader.js b/lib/templating/__tests__/conrefsLoader.js deleted file mode 100644 index 196b513..0000000 --- a/lib/templating/__tests__/conrefsLoader.js +++ /dev/null @@ -1,98 +0,0 @@ -var path = require('path'); - -var TemplateEngine = require('../../models/templateEngine'); -var renderTemplate = require('../render'); -var ConrefsLoader = require('../conrefsLoader'); - -describe('ConrefsLoader', function() { - var dirName = __dirname + '/'; - var fileName = path.join(dirName, 'test.md'); - - describe('Git', function() { - var engine = TemplateEngine({ - loader: new ConrefsLoader(dirName) - }); - - it('should include content from git', function() { - return renderTemplate(engine, fileName, '{% include "git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test.md" %}') - .then(function(out) { - expect(out.getContent()).toBe('Hello from git'); - }); - }); - - it('should handle deep inclusion (1)', function() { - return renderTemplate(engine, fileName, '{% include "git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test2.md" %}') - .then(function(out) { - expect(out.getContent()).toBe('First Hello. Hello from git'); - }); - }); - - it('should handle deep inclusion (2)', function() { - return renderTemplate(engine, fileName, '{% include "git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test3.md" %}') - .then(function(out) { - expect(out.getContent()).toBe('First Hello. Hello from git'); - }); - }); - }); - - describe('Local', function() { - var engine = TemplateEngine({ - loader: new ConrefsLoader(dirName) - }); - - describe('Relative', function() { - it('should resolve basic relative filepath', function() { - return renderTemplate(engine, fileName, '{% include "include.md" %}') - .then(function(out) { - expect(out.getContent()).toBe('Hello World'); - }); - }); - - it('should resolve basic parent filepath', function() { - return renderTemplate(engine, path.join(dirName, 'hello/test.md'), '{% include "../include.md" %}') - .then(function(out) { - expect(out.getContent()).toBe('Hello World'); - }); - }); - }); - - describe('Absolute', function() { - it('should resolve absolute filepath', function() { - return renderTemplate(engine, fileName, '{% include "/include.md" %}') - .then(function(out) { - expect(out.getContent()).toBe('Hello World'); - }); - }); - - it('should resolve absolute filepath when in a directory', function() { - return renderTemplate(engine, path.join(dirName, 'hello/test.md'), '{% include "/include.md" %}') - .then(function(out) { - expect(out.getContent()).toBe('Hello World'); - }); - }); - }); - }); - - describe('transform', function() { - function transform(filePath, source) { - expect(filePath).toBeA('string'); - expect(source).toBeA('string'); - - expect(filePath).toBe(path.resolve(__dirname, 'include.md')); - expect(source).toBe('Hello World'); - - return 'test-' + source + '-endtest'; - } - var engine = TemplateEngine({ - loader: new ConrefsLoader(dirName, transform) - }); - - it('should transform included content', function() { - return renderTemplate(engine, fileName, '{% include "include.md" %}') - .then(function(out) { - expect(out.getContent()).toBe('test-Hello World-endtest'); - }); - }); - }); -}); - |