From 7c2a6f215734d29f3be8c0a0c85307e896f48155 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sun, 9 Sep 2018 03:59:46 -0400 Subject: js: add cache singleton, support non-array cache templates --- js/test/cache.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'js/test') diff --git a/js/test/cache.js b/js/test/cache.js index 39dd46d..0b68b3d 100644 --- a/js/test/cache.js +++ b/js/test/cache.js @@ -3,6 +3,18 @@ var assert = chai.assert; it('cache', function() { + var cache = new LuigiTemplate.Cache({ + foo: 'foo%{bar}', + }); + + var r = cache.run('foo', { + bar: 'foo', + }); + + assert.equal(r, 'foofoo'); + }); + + it('cache with array', function() { var cache = new LuigiTemplate.Cache({ foo: ['foo%{bar}'], }); @@ -14,6 +26,19 @@ assert.equal(r, 'foofoo'); }); + it('cache singleton', function() { + var cache = LuigiTemplate.cache({ + foo: 'foo%{bar}', + }); + + var r = cache.run('foo', { + bar: 'foo', + }); + + assert.equal(r, 'foofoo'); + }); + + it('cache with custom filters', function() { var cache = new LuigiTemplate.Cache({ foo: ['foo%{bar | barify}'], -- cgit v1.2.3