refator: In spec tests, use expectTemplate over equals and shouldThrow (#1683)
This commit is contained in:
@@ -20,14 +20,18 @@ describe('javascript-compiler api', function() {
|
||||
return parent + '.bar_' + name;
|
||||
};
|
||||
/* eslint-disable camelcase */
|
||||
shouldCompileTo('{{foo}}', { bar_foo: 'food' }, 'food');
|
||||
expectTemplate('{{foo}}')
|
||||
.withInput({ bar_foo: 'food' })
|
||||
.toCompileTo('food');
|
||||
/* eslint-enable camelcase */
|
||||
});
|
||||
|
||||
// Tests nameLookup dot vs. bracket behavior. Bracket is required in certain cases
|
||||
// to avoid errors in older browsers.
|
||||
it('should handle reserved words', function() {
|
||||
shouldCompileTo('{{foo}} {{~null~}}', { foo: 'food' }, 'food');
|
||||
expectTemplate('{{foo}} {{~null~}}')
|
||||
.withInput({ foo: 'food' })
|
||||
.toCompileTo('food');
|
||||
});
|
||||
});
|
||||
describe('#compilerInfo', function() {
|
||||
@@ -49,7 +53,9 @@ describe('javascript-compiler api', function() {
|
||||
throw new Error("It didn't work");
|
||||
}
|
||||
};
|
||||
shouldCompileTo('{{foo}} ', { foo: 'food' }, 'food ');
|
||||
expectTemplate('{{foo}} ')
|
||||
.withInput({ foo: 'food' })
|
||||
.toCompileTo('food ');
|
||||
});
|
||||
});
|
||||
describe('buffer', function() {
|
||||
@@ -70,7 +76,9 @@ describe('javascript-compiler api', function() {
|
||||
handlebarsEnv.JavaScriptCompiler.prototype.initializeBuffer = function() {
|
||||
return this.quotedString('foo_');
|
||||
};
|
||||
shouldCompileTo('{{foo}} ', { foo: 'food' }, 'foo_food ');
|
||||
expectTemplate('{{foo}} ')
|
||||
.withInput({ foo: 'food' })
|
||||
.toCompileTo('foo_food ');
|
||||
});
|
||||
it('should allow append buffer override', function() {
|
||||
handlebarsEnv.JavaScriptCompiler.prototype.appendToBuffer = function(
|
||||
@@ -78,7 +86,9 @@ describe('javascript-compiler api', function() {
|
||||
) {
|
||||
return $superAppend.call(this, [string, ' + "_foo"']);
|
||||
};
|
||||
shouldCompileTo('{{foo}}', { foo: 'food' }, 'food_foo');
|
||||
expectTemplate('{{foo}}')
|
||||
.withInput({ foo: 'food' })
|
||||
.toCompileTo('food_foo');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user