Fix test runners under node
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
global.handlebarsEnv = null;
|
||||
|
||||
beforeEach(function() {
|
||||
global.handlebarsEnv = new Handlebars.HandlebarsEnvironment();
|
||||
global.handlebarsEnv = Handlebars.create();
|
||||
});
|
||||
|
||||
describe("basic context", function() {
|
||||
|
||||
Vendored
+9
-4
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
Vendored
+4
-7
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
Vendored
+5
-6
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
Vendored
+15
-6
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user