Skip to content
This repository has been archived by the owner on Apr 11, 2018. It is now read-only.

Commit

Permalink
Solidify tests for requiring conditional in if statements
Browse files Browse the repository at this point in the history
  • Loading branch information
paularmstrong committed Mar 7, 2014
1 parent 57c2dae commit 3855260
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions tests/tags/else.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,10 @@ describe('Tag: elseif, elif', function () {
swig.render('{% elseif true %}foo');
}).to.throwError(/Unexpected tag "elseif" on line 1\./);
});

it('requires a conditional', function () {
expect(function () {
swig.render('{% if true %}{% elif %}foo');
}).to.throwError(/No conditional statement provided on line 1\./);
});
});
7 changes: 6 additions & 1 deletion tests/tags/if.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ var opts = {
};

var cases = [
{ code: undefined, result: false },
{ code: 'foo', result: true },
{ code: 'true', result: true },
{ code: 'false', result: false },
Expand Down Expand Up @@ -52,6 +51,12 @@ describe('Tag: if', function () {
});
});

it('requires a conditional', function () {
expect(function () {
swig.render('{% if %}tacos{% endif %}');
}).to.throwError(/No conditional statement provided on line 1\./);
});

it('throws on bad logic', function () {
var baddies = [
[ '{% if && foo %}{% endif %}', /Unexpected logic "\&\&" on line 1\./ ],
Expand Down

0 comments on commit 3855260

Please sign in to comment.