summaryrefslogtreecommitdiffstats
path: root/lib/templating/__tests__
diff options
context:
space:
mode:
Diffstat (limited to 'lib/templating/__tests__')
-rw-r--r--lib/templating/__tests__/conrefsLoader.js98
-rw-r--r--lib/templating/__tests__/include.md1
-rw-r--r--lib/templating/__tests__/postRender.js51
-rw-r--r--lib/templating/__tests__/replaceShortcuts.js27
4 files changed, 0 insertions, 177 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');
- });
- });
- });
-});
-
diff --git a/lib/templating/__tests__/include.md b/lib/templating/__tests__/include.md
deleted file mode 100644
index 5e1c309..0000000
--- a/lib/templating/__tests__/include.md
+++ /dev/null
@@ -1 +0,0 @@
-Hello World \ No newline at end of file
diff --git a/lib/templating/__tests__/postRender.js b/lib/templating/__tests__/postRender.js
deleted file mode 100644
index 131e29b..0000000
--- a/lib/templating/__tests__/postRender.js
+++ /dev/null
@@ -1,51 +0,0 @@
-var TemplateEngine = require('../../models/templateEngine');
-var TemplateBlock = require('../../models/templateBlock');
-
-var renderTemplate = require('../render');
-var postRender = require('../postRender');
-
-describe('postRender', function() {
- var testPost;
- var engine = TemplateEngine.create({
- blocks: [
- TemplateBlock.create('lower', function(blk) {
- return blk.body.toLowerCase();
- }),
- TemplateBlock.create('prefix', function(blk) {
- return {
- body: '_' + blk.body + '_',
- post: function() {
- testPost = true;
- }
- };
- })
- ]
- });
-
- it('should correctly replace block', function() {
- return renderTemplate(engine, 'README.md', 'Hello {% lower %}Samy{% endlower %}')
- .then(function(output) {
- expect(output.getContent()).toMatch(/Hello \{\{\-([\S]+)\-\}\}/);
- expect(output.getBlocks().size).toBe(1);
-
- return postRender(engine, output);
- })
- .then(function(result) {
- expect(result).toBe('Hello samy');
- });
- });
-
- it('should correctly replace blocks', function() {
- return renderTemplate(engine, 'README.md', 'Hello {% lower %}Samy{% endlower %}{% prefix %}Pesse{% endprefix %}')
- .then(function(output) {
- expect(output.getContent()).toMatch(/Hello \{\{\-([\S]+)\-\}\}\{\{\-([\S]+)\-\}\}/);
- expect(output.getBlocks().size).toBe(2);
- return postRender(engine, output);
- })
- .then(function(result) {
- expect(result).toBe('Hello samy_Pesse_');
- expect(testPost).toBe(true);
- });
- });
-
-});
diff --git a/lib/templating/__tests__/replaceShortcuts.js b/lib/templating/__tests__/replaceShortcuts.js
deleted file mode 100644
index 216a1c8..0000000
--- a/lib/templating/__tests__/replaceShortcuts.js
+++ /dev/null
@@ -1,27 +0,0 @@
-var Immutable = require('immutable');
-
-var TemplateBlock = require('../../models/templateBlock');
-var replaceShortcuts = require('../replaceShortcuts');
-
-describe('replaceShortcuts', function() {
- var blocks = Immutable.List([
- TemplateBlock.create('math', {
- shortcuts: {
- start: '$$',
- end: '$$',
- parsers: ['markdown']
- }
- })
- ]);
-
- it('should correctly replace inline matches by block', function() {
- var content = replaceShortcuts(blocks, 'test.md', 'Hello $$a = b$$');
- expect(content).toBe('Hello {% math %}a = b{% endmath %}');
- });
-
- it('should correctly replace block matches', function() {
- var content = replaceShortcuts(blocks, 'test.md', 'Hello\n$$\na = b\n$$\n');
- expect(content).toBe('Hello\n{% math %}\na = b\n{% endmath %}\n');
- });
-});
-