Fix test runners under node

This commit is contained in:
kpdecker
2013-10-09 03:22:05 -07:00
parent 4d7124f6bf
commit 3b0a3ca1b2
5 changed files with 34 additions and 24 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
global.handlebarsEnv = null;
beforeEach(function() {
global.handlebarsEnv = new Handlebars.HandlebarsEnvironment();
global.handlebarsEnv = Handlebars.create();
});
describe("basic context", function() {
+9 -4
View File
@@ -1,13 +1,18 @@
require('./common');
global.Handlebars = require('../../dist/handlebars');
var _ = require('underscore'),
fs = require('fs'),
vm = require('vm');
global.Handlebars = undefined;
vm.runInThisContext(fs.readFileSync(__dirname + '/../../dist/handlebars.js'), 'dist/handlebars.js');
global.CompilerContext = {
compile: function(template, options) {
var templateSpec = Handlebars.precompile(template, options);
return Handlebars.template(eval('(' + templateSpec + ')'));
var templateSpec = handlebarsEnv.precompile(template, options);
return handlebarsEnv.template(eval('(' + templateSpec + ')'));
},
compileWithPartial: function(template, options) {
return Handlebars.compile(template, options);
return handlebarsEnv.compile(template, options);
}
};
+4 -7
View File
@@ -3,14 +3,11 @@ require('./common');
global.Handlebars = require('../../lib');
global.CompilerContext = {
compile: function(template, options, env) {
env = env || handlebarsEnv;
var templateSpec = Handlebars.precompile(template, options);
return Handlebars.template(eval('(' + templateSpec + ')'), env);
compile: function(template, options) {
var templateSpec = handlebarsEnv.precompile(template, options);
return handlebarsEnv.template(eval('(' + templateSpec + ')'));
},
compileWithPartial: function(template, options) {
options = options || {};
options.env = handlebarsEnv;
return Handlebars.compile(template, options);
return handlebarsEnv.compile(template, options);
}
};
+5 -6
View File
@@ -13,12 +13,11 @@ var files = fs.readdirSync(testDir)
.map(function(name) { return testDir + '/' + name; });
run('./node', function() {
process.exit(errors);
//run('./browser', function() {
//run('./runtime', function() {
//process.exit(errors);
//});
//});
run('./browser', function() {
run('./runtime', function() {
process.exit(errors);
});
});
});
+15 -6
View File
@@ -1,15 +1,24 @@
require('./common');
global.Handlebars = require('../../dist/handlebars.runtime');
var _ = require('underscore'),
fs = require('fs'),
vm = require('vm');
var compiler = require('../../lib/handlebars');
global.Handlebars = undefined;
vm.runInThisContext(fs.readFileSync(__dirname + '/../../dist/handlebars.runtime.js'), 'dist/handlebars.runtime.js');
var compiler = require('../../dist/cjs/handlebars/compiler/compiler');
global.CompilerContext = {
compile: function(template, options, env) {
compile: function(template, options) {
var templateSpec = compiler.precompile(template, options);
return Handlebars.template(eval('(' + templateSpec + ')'), env);
return handlebarsEnv.template(eval('(' + templateSpec + ')'));
},
compileWithPartial: function(template, options, env) {
return compiler.compile(template, options);
compileWithPartial: function(template, options) {
// Hack the compiler on to the environment for these specific tests
handlebarsEnv.compile = function(template, options) {
return compiler.compile(template, options, handlebarsEnv);
};
return handlebarsEnv.compile(template, options);
}
};