From e9ff3d916d7e0c4f9bbefe719eabe8c0736a3aa2 Mon Sep 17 00:00:00 2001 From: harttle Date: Sun, 6 Nov 2016 15:42:30 +0800 Subject: [PATCH] refactor unit test for tags/unless --- test/tags/unless.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/tags/unless.js b/test/tags/unless.js index 43921d6e2..dbb5c93f9 100644 --- a/test/tags/unless.js +++ b/test/tags/unless.js @@ -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(''); });