mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 21:00:40 -07:00
coverage
This commit is contained in:
+3
-3
@@ -23,7 +23,7 @@ describe('tag', function() {
|
||||
type: 'tag',
|
||||
value: 'foo',
|
||||
name: 'foo'
|
||||
});
|
||||
}, []);
|
||||
}).to.throw(/tag foo not found/);
|
||||
});
|
||||
|
||||
@@ -52,7 +52,7 @@ describe('tag', function() {
|
||||
type: 'tag',
|
||||
value: 'foo',
|
||||
name: 'foo'
|
||||
}).render(scope, {});
|
||||
}, []).render(scope, {});
|
||||
expect(spy).to.have.been.called;
|
||||
});
|
||||
|
||||
@@ -68,7 +68,7 @@ describe('tag', function() {
|
||||
name: 'foo',
|
||||
args: 'aa:foo bb: arr[0] cc: 2.3'
|
||||
};
|
||||
tag.construct(token).render(scope, {});
|
||||
tag.construct(token, []).render(scope, {});
|
||||
expect(spy).to.have.been.calledWithMatch(scope, {
|
||||
aa: 'bar',
|
||||
bb: 2,
|
||||
|
||||
@@ -27,11 +27,13 @@ describe('tags', function() {
|
||||
emptyArray: []
|
||||
};
|
||||
});
|
||||
|
||||
it('should support assign', function() {
|
||||
test('{% assign foo="bar" %}{{foo}}', 'bar');
|
||||
test('{% assign foo=(1..3) %}{{foo}}', '[1,2,3]');
|
||||
test('{% assign foo="a b" | capitalize | split: " " | first %}{{foo}}', 'A');
|
||||
});
|
||||
|
||||
it('should support case', function() {
|
||||
testThrow('{% case "foo"%}', /{% case "foo"%} not closed/);
|
||||
test('{% case "foo"%}' +
|
||||
@@ -69,10 +71,22 @@ describe('tags', function() {
|
||||
testThrow('{% capture = %}{%endcapture%}', /= not valid identifier/);
|
||||
});
|
||||
|
||||
it('should throw when for capture closed', function() {
|
||||
testThrow('{%capture c%}{{c}}', /tag .* not closed/);
|
||||
});
|
||||
|
||||
it('should support for', function() {
|
||||
test('{%for c in alpha%}{{c}}{%endfor%}', 'abc');
|
||||
});
|
||||
|
||||
it('should throw when for not closed', function() {
|
||||
testThrow('{%for c in alpha%}{{c}}', /tag .* not closed/);
|
||||
});
|
||||
|
||||
it('should support for else', function() {
|
||||
test('{%for c in ""%}a{%else%}b{%endfor%}', 'b');
|
||||
});
|
||||
|
||||
it('should support for with forloop', function() {
|
||||
src = '{%for c in alpha%}' +
|
||||
'{{forloop.first}}.{{forloop.index}}.{{forloop.index0}}.' +
|
||||
@@ -117,6 +131,10 @@ describe('tags', function() {
|
||||
test(src + src + src + src, '1231');
|
||||
});
|
||||
|
||||
it('should throw when cycle candidates empty', function() {
|
||||
testThrow('{%cycle%}', /empty candidates/);
|
||||
});
|
||||
|
||||
it('should support cycle in for block', function() {
|
||||
src = '{% for i in (1..5) %}{% cycle one, "e"%}{% endfor %}';
|
||||
test(src, '1e1e1');
|
||||
|
||||
Reference in New Issue
Block a user