Bump test coverage
This commit is contained in:
@@ -98,7 +98,8 @@ export function prepareProgram(statements, isRoot) {
|
||||
if (omitLeft(statements, i)) {
|
||||
// If we are on a standalone node, save the indent info for partials
|
||||
if (current.type === 'partial') {
|
||||
current.indent = (/([ \t]+$)/).exec(statements[i-1].original) ? RegExp.$1 : '';
|
||||
// Pull out the whitespace from the final line
|
||||
current.indent = (/([ \t]+$)/).exec(statements[i-1].original)[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -732,8 +732,8 @@ JavaScriptCompiler.prototype = {
|
||||
usedLiteral = true;
|
||||
} else {
|
||||
// Get or create the current stack name for use by the inline
|
||||
createdStack = !this.stackSlot;
|
||||
var name = !createdStack ? this.topStackName() : this.incrStack();
|
||||
createdStack = true;
|
||||
var name = this.incrStack();
|
||||
|
||||
prefix = '(' + this.push(name) + ' = ' + top + ')';
|
||||
stack = this.topStack();
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
a
|
||||
+30
-1
@@ -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'}; };
|
||||
|
||||
Reference in New Issue
Block a user