Skip to content

Commit

Permalink
Add tests for built-in helper inconsistent errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ErisDS committed Oct 25, 2019
1 parent a15d01d commit 96aab4a
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions spec/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -766,4 +766,70 @@ describe('helpers', function() {
shouldCompileTo('{{#if bar}}{{else goodbyes as |value|}}{{value}}{{/if}}{{value}}', [hash, helpers], '1foo');
});
});

describe.only('built-in helpers malformed arguments ', function() {
it('if helper - too few arguments', function() {
var template = CompilerContext.compile('{{#if}}{{/if}}');
shouldThrow(function() {

template({});
}, undefined, /Cannot read property 'hash' of undefined/);
});

it('if helper - too many arguments, string', function() {
var template = CompilerContext.compile('{{#if test "string"}}{{/if}}');
shouldThrow(function() {

template({});
}, undefined, /Cannot read property 'includeZero' of undefined/);
});

it('if helper - too many arguments, undefined', function() {
var template = CompilerContext.compile('{{#if test undefined}}{{/if}}');
shouldThrow(function() {

template({});
}, undefined, /Cannot read property 'hash' of undefined/);
});

it('if helper - too many arguments, null', function() {
var template = CompilerContext.compile('{{#if test null}}{{/if}}');
shouldThrow(function() {

template({});
}, undefined, /Cannot read property 'hash' of null/);
});

it('unless helper - too few arguments', function() {
var template = CompilerContext.compile('{{#unless}}{{/unless}}');
shouldThrow(function() {

template({});
}, undefined, /Cannot read property 'inverse' of undefined/);
});

it('unless helper - too many arguments', function() {
var template = CompilerContext.compile('{{#unless test null}}{{/unless}}');
shouldThrow(function() {

template({});
}, undefined, /Cannot read property 'inverse' of null/);
});

it('with helper - too few arguments', function() {
var template = CompilerContext.compile('{{#with}}{{/with}}');
shouldThrow(function() {

template({});
}, undefined, /Cannot read property 'fn' of undefined/);
});

it('with helper - too many arguments', function() {
var template = CompilerContext.compile('{{#with test "string"}}{{/with}}');
shouldThrow(function() {

template({});
}, undefined, /options.inverse is not a function/);
});
});
});

0 comments on commit 96aab4a

Please sign in to comment.