test cases for #53

This commit is contained in:
harttle
2017-12-29 12:17:52 +08:00
parent 757a06ee83
commit 900664a26d
+13 -3
View File
@@ -5,19 +5,29 @@ chai.use(require('chai-as-promised'))
describe('tags/comment', function () { describe('tags/comment', function () {
var liquid = Liquid() var liquid = Liquid()
it('should support comment 1', function () { it('should support empty content', function () {
var src = '{% comment %}{% raw%}' var src = '{% comment %}{% raw%}'
return expect(liquid.parseAndRender(src)) return expect(liquid.parseAndRender(src))
.to.be.rejectedWith(/{% comment %} not closed/) .to.be.rejectedWith(/{% comment %} not closed/)
}) })
it('should support comment 2', function () { it('should ignore plain string', function () {
var src = 'My name is {% comment %}super{% endcomment %} Shopify.' var src = 'My name is {% comment %}super{% endcomment %} Shopify.'
return expect(liquid.parseAndRender(src)) return expect(liquid.parseAndRender(src))
.to.eventually.equal('My name is Shopify.') .to.eventually.equal('My name is Shopify.')
}) })
it('should support comment 3', function () { it('should ignore output tokens', function () {
var src = '{% comment %}\n{{ foo}} \n{% endcomment %}' var src = '{% comment %}\n{{ foo}} \n{% endcomment %}'
return expect(liquid.parseAndRender(src)) return expect(liquid.parseAndRender(src))
.to.eventually.equal('') .to.eventually.equal('')
}) })
it('should ignore tag tokens', function () {
var src = '{% comment %}{%if true%}true{%else%}false{%endif%}{% endcomment %}'
return expect(liquid.parseAndRender(src))
.to.eventually.equal('')
})
it('should ignore un-balenced tag tokens', function () {
var src = '{% comment %}{%if true%}true{%else%}false{% endcomment %}'
return expect(liquid.parseAndRender(src))
.to.eventually.equal('')
})
}) })