From 2cff700e3e59adc2bfcd4b2c536675dfdeb96312 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sun, 9 Sep 2018 03:50:48 -0400 Subject: js: rm test.js, add test/{test.html,*.js} based on mocha/chai --- js/test/template.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 js/test/template.js (limited to 'js/test/template.js') diff --git a/js/test/template.js b/js/test/template.js new file mode 100644 index 0000000..9a0018f --- /dev/null +++ b/js/test/template.js @@ -0,0 +1,33 @@ +(function() { + 'use strict'; + var assert = chai.assert; + + it('run', function() { + var t = new LuigiTemplate('foo%{bar}'), + r = t.run({ bar: 'foo' }); + + assert.equal(r, 'foofoo'); + }); + + it('run singleton', function() { + var r = LuigiTemplate.run('foo%{bar}', { bar: 'foo' }); + + assert.equal(r, 'foofoo'); + }); + + it('run with multiple keys', function() { + var r = LuigiTemplate.run('foo%{bar}%{baz}', { + bar: 'foo', + baz: 'foo', + }); + + assert.equal(r, 'foofoofoo'); + }); + + it('run with whitespace around key', function() { + var s = "%{ \t\v\r\nbar}%{ \t\v\r\nbar \t\v\r\n}%{bar \t\v\r\n}", + r = LuigiTemplate.run(s, { bar: 'foo' }); + + assert.equal(r, 'foofoofoo'); + }); +})(); -- cgit v1.2.3