mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -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() {
|
||||
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%}';
|
||||
return expect(liquid.parseAndRender(src))
|
||||
.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';
|
||||
return expect(liquid.parseAndRender(src))
|
||||
.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%}';
|
||||
return expect(liquid.parseAndRender(src))
|
||||
.to.eventually.equal('yes');
|
||||
});
|
||||
it('should support unless 4', function() {
|
||||
var src = '{% unless true %}{%endunless%}';
|
||||
it('should render "" when predicate yields false and else undefined', function() {
|
||||
var src = '{% unless 1<2 %}yes{%endunless%}';
|
||||
return expect(liquid.parseAndRender(src))
|
||||
.to.eventually.equal('');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user