diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-05-04 20:18:48 +0200 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-05-04 20:18:48 +0200 |
commit | c621380b664bcbef087df571b662e7a34e098168 (patch) | |
tree | 9a416eb1399b5474c879d67fbd0ff5d6811eb25a /lib/templating | |
parent | c4b54033cefe54f2c7fda92b8765ed500178ea74 (diff) | |
download | gitbook-c621380b664bcbef087df571b662e7a34e098168.zip gitbook-c621380b664bcbef087df571b662e7a34e098168.tar.gz gitbook-c621380b664bcbef087df571b662e7a34e098168.tar.bz2 |
Add tests for replaceShortcuts
Diffstat (limited to 'lib/templating')
-rw-r--r-- | lib/templating/__tests__/replaceShortcuts.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/templating/__tests__/replaceShortcuts.js b/lib/templating/__tests__/replaceShortcuts.js new file mode 100644 index 0000000..bd94f29 --- /dev/null +++ b/lib/templating/__tests__/replaceShortcuts.js @@ -0,0 +1,28 @@ +var TemplateEngine = require('../../models/templateEngine'); +var TemplateBlock = require('../../models/templateBlock'); +var replaceShortcuts = require('../replaceShortcuts'); + +describe('replaceShortcuts', function() { + var engine = TemplateEngine.create({ + blocks:[ + TemplateBlock.create('math', { + shortcuts: { + start: '$$', + end: '$$', + parsers: ['markdown'] + } + }) + ] + }); + + it('should correctly replace inline matches by block', function() { + var content = replaceShortcuts(engine, 'test.md', 'Hello $$a = b$$'); + expect(content).toBe('Hello {% math %}a = b{% endmath %}'); + }); + + it('should correctly replace block matches', function() { + var content = replaceShortcuts(engine, 'test.md', 'Hello\n$$\na = b\n$$\n'); + expect(content).toBe('Hello\n{% math %}\na = b\n{% endmath %}\n'); + }); +}); + |