mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
add unit test for #21
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@ const re = new RegExp(`^(${lexical.identifier.source})\\s+in\\s+` +
|
||||
`(${lexical.value.source})` +
|
||||
`(?:\\s+${lexical.hash.source})*` +
|
||||
`(?:\\s+(reversed))?` +
|
||||
`(?:\\s+${lexical.hash.source})*`);
|
||||
`(?:\\s+${lexical.hash.source})*$`);
|
||||
|
||||
module.exports = function(liquid) {
|
||||
liquid.registerTag('for', {
|
||||
|
||||
+13
-1
@@ -74,9 +74,21 @@ describe('tags/for', function() {
|
||||
.to.eventually.equal('67');
|
||||
});
|
||||
|
||||
it('should support for reversed', function() {
|
||||
it('should support for reversed in the last position', function() {
|
||||
var src = '{% for i in (1..5) limit:2 reversed %}{{ i }}{% endfor %}';
|
||||
return expect(liquid.parseAndRender(src, ctx))
|
||||
.to.eventually.equal('21');
|
||||
});
|
||||
|
||||
it('should support for reversed in the middle position', function() {
|
||||
var src = '{% for i in (1..5) reversed limit:2 %}{{ i }}{% endfor %}';
|
||||
return expect(liquid.parseAndRender(src, ctx))
|
||||
.to.eventually.equal('21');
|
||||
});
|
||||
|
||||
it('should support for reversed in the first position', function() {
|
||||
var src = '{% for i in (1..5) offset:2 reversed limit:4 %}{{ i }}{% endfor %}';
|
||||
return expect(liquid.parseAndRender(src, ctx))
|
||||
.to.eventually.equal('543');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user