diff options
author | kpdecker <kpdecker@gmail.com> | 2014-11-07 21:23:51 -0600 |
---|---|---|
committer | kpdecker <kpdecker@gmail.com> | 2014-11-08 14:35:23 -0600 |
commit | d47e4dd1f742ae90d71b4fd5141a0e7577098cc5 (patch) | |
tree | 53067edaf558fe7bc02fbe804f50953ee99befae /spec/precompiler.js | |
parent | 83bcbee222077350ee2b7e3322f0cdad18f34b83 (diff) | |
download | handlebars.js-d47e4dd1f742ae90d71b4fd5141a0e7577098cc5.zip handlebars.js-d47e4dd1f742ae90d71b4fd5141a0e7577098cc5.tar.gz handlebars.js-d47e4dd1f742ae90d71b4fd5141a0e7577098cc5.tar.bz2 |
Bump test coverage
Diffstat (limited to 'spec/precompiler.js')
-rw-r--r-- | spec/precompiler.js | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/spec/precompiler.js b/spec/precompiler.js index bd19fbf..9d883b6 100644 --- a/spec/precompiler.js +++ b/spec/precompiler.js @@ -9,27 +9,38 @@ describe('precompiler', function() { var Handlebars = require('../lib'), Precompiler = require('../lib/precompiler'), + fs = require('fs'), uglify = require('uglify-js'); var log, logFunction, precompile, - minify; + minify, + + file, + content, + writeFileSync; beforeEach(function() { precompile = Handlebars.precompile; minify = uglify.minify; + writeFileSync = fs.writeFileSync; logFunction = console.log; log = ''; console.log = function() { log += Array.prototype.join.call(arguments, ''); }; + fs.writeFileSync = function(_file, _content) { + file = _file; + content = _content; + }; }); afterEach(function() { Handlebars.precompile = precompile; uglify.minify = minify; + fs.writeFileSync = writeFileSync; console.log = logFunction; }); @@ -121,6 +132,24 @@ describe('precompiler', function() { equal(log, 'simple\n'); }); + it('should handle different root', function() { + Handlebars.precompile = function() { return 'simple'; }; + Precompiler.cli({templates: [__dirname + '/artifacts/empty.handlebars'], simple: true, extension: 'handlebars', root: 'foo/'}); + equal(log, 'simple\n'); + }); + it('should output to file system', function() { + Handlebars.precompile = function() { return 'simple'; }; + Precompiler.cli({templates: [__dirname + '/artifacts/empty.handlebars'], simple: true, extension: 'handlebars', output: 'file!'}); + equal(file, 'file!'); + equal(content, 'simple\n'); + equal(log, ''); + }); + it('should handle BOM', function() { + Handlebars.precompile = function(template) { return template === 'a' ? 'simple' : 'fail'; }; + Precompiler.cli({templates: [__dirname + '/artifacts/bom.handlebars'], simple: true, extension: 'handlebars', bom: true}); + equal(log, 'simple\n'); + }); + it('should output minimized templates', function() { Handlebars.precompile = function() { return 'amd'; }; uglify.minify = function() { return {code: 'min'}; }; |