Skip to content

Commit

Permalink
Only run "require" tests when require() is available
Browse files Browse the repository at this point in the history
  • Loading branch information
jjclark1982 committed May 15, 2013
1 parent 229b82b commit d649b35
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions spec/qunit_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1475,26 +1475,6 @@ test('GH-375: Unicode line terminators', function() {
shouldCompileTo('\u2028', {}, '\u2028');
});

test('Load .handlebars files with require()', function() {
var template = require("./example_1");
assert.deepEqual(template, require("./example_1.handlebars"));

var expected = 'foo\n';
var result = template({foo: "foo"});

equal(result, expected);
});

test('Load .hbs files with require()', function() {
var template = require("./example_2");
assert.deepEqual(template, require("./example_2.hbs"));

var expected = 'Hello, World!\n';
var result = template({name: "World"});

equal(result, expected);
});

suite('Utils');

test('escapeExpression', function() {
Expand Down Expand Up @@ -1522,3 +1502,27 @@ test('isEmpty', function() {
equal(Handlebars.Utils.isEmpty('foo'), false);
equal(Handlebars.Utils.isEmpty({bar: 1}), false);
});

if (typeof(require) !== 'undefined') {
suite('Require');

test('Load .handlebars files with require()', function() {
var template = require("./example_1");
assert.deepEqual(template, require("./example_1.handlebars"));

var expected = 'foo\n';
var result = template({foo: "foo"});

equal(result, expected);
});

test('Load .hbs files with require()', function() {
var template = require("./example_2");
assert.deepEqual(template, require("./example_2.hbs"));

var expected = 'Hello, World!\n';
var result = template({name: "World"});

equal(result, expected);
});
}

0 comments on commit d649b35

Please sign in to comment.