diff options
author | kpdecker <kpdecker@gmail.com> | 2014-08-23 18:52:30 -0500 |
---|---|---|
committer | kpdecker <kpdecker@gmail.com> | 2014-08-23 18:52:30 -0500 |
commit | 2b3fdf7ea80bb7af8e6317c2ce30a4ce3236e7f6 (patch) | |
tree | b5147e7095aa4c17ef23f22c50bb95516b9658bc /spec/precompiler.js | |
parent | 0c7c37df6aa31a3e70f9eecadcaaa25928921c94 (diff) | |
download | handlebars.js-2b3fdf7ea80bb7af8e6317c2ce30a4ce3236e7f6.zip handlebars.js-2b3fdf7ea80bb7af8e6317c2ce30a4ce3236e7f6.tar.gz handlebars.js-2b3fdf7ea80bb7af8e6317c2ce30a4ce3236e7f6.tar.bz2 |
Additional test coverage cleanup
Also fixes the template._child implementation which broke with the depthed work.
Diffstat (limited to 'spec/precompiler.js')
-rw-r--r-- | spec/precompiler.js | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/spec/precompiler.js b/spec/precompiler.js index 3b66353..0310681 100644 --- a/spec/precompiler.js +++ b/spec/precompiler.js @@ -1,5 +1,7 @@ /*global shouldThrow */ +var uglify = require('uglify-js'); + describe('precompiler', function() { // NOP Under non-node environments if (typeof process === 'undefined') { @@ -12,10 +14,13 @@ describe('precompiler', function() { var log, logFunction, - precompile; + precompile, + minify; beforeEach(function() { precompile = Handlebars.precompile; + minify = uglify.minify; + logFunction = console.log; log = ''; console.log = function() { @@ -24,6 +29,7 @@ describe('precompiler', function() { }); afterEach(function() { Handlebars.precompile = precompile; + uglify.minify = minify; console.log = logFunction; }); @@ -65,6 +71,10 @@ describe('precompiler', function() { equal(/'empty'/.test(log), true); equal(/'example_1'/.test(log), true); }); + it('should protect from regexp patterns', function() { + Precompiler.cli({templates: [__dirname + '/artifacts'], extension: 'hb(s'}); + // Success is not throwing + }); it('should output simple templates', function() { Handlebars.precompile = function() { return 'simple'; }; Precompiler.cli({templates: [__dirname + '/artifacts/empty.handlebars'], simple: true, extension: 'handlebars'}); @@ -110,4 +120,11 @@ describe('precompiler', function() { Precompiler.cli({templates: [__dirname + '/artifacts/empty.handlebars'], simple: true, extension: 'handlebars', known: 'foo'}); equal(log, 'simple\n'); }); + + it('should output minimized templates', function() { + Handlebars.precompile = function() { return 'amd'; }; + uglify.minify = function() { return {code: 'min'}; }; + Precompiler.cli({templates: [__dirname + '/artifacts/empty.handlebars'], min: true, extension: 'handlebars'}); + equal(log, 'min'); + }); }); |