mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-19 14:30:38 -07:00
refactor unit test for tags/unless
This commit is contained in:
+10
-5
@@ -6,23 +6,28 @@ chai.use(require("chai-as-promised"));
|
|||||||
describe('tags/unless', function() {
|
describe('tags/unless', function() {
|
||||||
var liquid = Liquid();
|
var liquid = Liquid();
|
||||||
|
|
||||||
it('should support unless 1', function() {
|
it('should render else when predicate yields true', function() {
|
||||||
var src = '{% unless 1 %}yes{%else%}no{%endunless%}';
|
var src = '{% unless 1 %}yes{%else%}no{%endunless%}';
|
||||||
return expect(liquid.parseAndRender(src))
|
return expect(liquid.parseAndRender(src))
|
||||||
.to.eventually.equal('no');
|
.to.eventually.equal('no');
|
||||||
});
|
});
|
||||||
it('should support unless 2', function() {
|
it('should render unless when predicate yields false', function() {
|
||||||
|
var src = '{% unless 0 %}yes{%else%}no{%endunless%}';
|
||||||
|
return expect(liquid.parseAndRender(src))
|
||||||
|
.to.eventually.equal('yes');
|
||||||
|
});
|
||||||
|
it('should reject when tag not closed', function() {
|
||||||
var src = '{% unless 1>2 %}yes';
|
var src = '{% unless 1>2 %}yes';
|
||||||
return expect(liquid.parseAndRender(src))
|
return expect(liquid.parseAndRender(src))
|
||||||
.to.be.rejectedWith(/tag {% unless 1>2 %} not closed/);
|
.to.be.rejectedWith(/tag {% unless 1>2 %} not closed/);
|
||||||
});
|
});
|
||||||
it('should support unless 3', function() {
|
it('should render unless when predicate yields false and else undefined', function() {
|
||||||
var src = '{% unless 1>2 %}yes{%endunless%}';
|
var src = '{% unless 1>2 %}yes{%endunless%}';
|
||||||
return expect(liquid.parseAndRender(src))
|
return expect(liquid.parseAndRender(src))
|
||||||
.to.eventually.equal('yes');
|
.to.eventually.equal('yes');
|
||||||
});
|
});
|
||||||
it('should support unless 4', function() {
|
it('should render "" when predicate yields false and else undefined', function() {
|
||||||
var src = '{% unless true %}{%endunless%}';
|
var src = '{% unless 1<2 %}yes{%endunless%}';
|
||||||
return expect(liquid.parseAndRender(src))
|
return expect(liquid.parseAndRender(src))
|
||||||
.to.eventually.equal('');
|
.to.eventually.equal('');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user