diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-05-12 12:19:00 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-05-12 12:19:00 +0200 |
commit | a091c5b331282bbcc4e0a3b79fbc32dd6f842747 (patch) | |
tree | 39bcc8a395111f059f4e65dc44f072b28a3d10a3 /lib/templating/__tests__/conrefsLoader.js | |
parent | 784b3379b50bb0c2986efaca55940d14feb10d3a (diff) | |
download | gitbook-a091c5b331282bbcc4e0a3b79fbc32dd6f842747.zip gitbook-a091c5b331282bbcc4e0a3b79fbc32dd6f842747.tar.gz gitbook-a091c5b331282bbcc4e0a3b79fbc32dd6f842747.tar.bz2 |
Fix path resolution when generating page with conrefs
Diffstat (limited to 'lib/templating/__tests__/conrefsLoader.js')
-rw-r--r-- | lib/templating/__tests__/conrefsLoader.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/templating/__tests__/conrefsLoader.js b/lib/templating/__tests__/conrefsLoader.js index 8bf4ad2..bcbee05 100644 --- a/lib/templating/__tests__/conrefsLoader.js +++ b/lib/templating/__tests__/conrefsLoader.js @@ -35,6 +35,44 @@ describe('ConrefsLoader', function() { }); }); + 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) { return 'test-' + source + '-endtest'; |