mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-17 21:40:39 -07:00
Coverage
This commit is contained in:
@@ -2,14 +2,14 @@
|
||||
|
||||
[](https://www.npmjs.org/package/shopify-liquid)
|
||||
[](https://travis-ci.org/harttle/shopify-liquid)
|
||||
[](https://coveralls.io/github/harttle/shopify-liquid?branch=master)
|
||||
[](https://coveralls.io/github/harttle/shopify-liquid?branch=master)
|
||||
[](https://david-dm.org/harttle/shopify-liquid)
|
||||
|
||||
[Liquid][shopify-liquid] implementation for Node.js.
|
||||
All tags and filters listed in [Shopify Documentation][shopify-liquid]
|
||||
shall be implemented.
|
||||
|
||||
> Shopify liquid is used by [Jekyll][jekyll] and [Github Pages][gh].
|
||||
> [Shopify liquid][shopify-liquid] is used by [Jekyll][jekyll] and [Github Pages][gh].
|
||||
|
||||
## Operators
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "shopify-liquid",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.1",
|
||||
"description": "A Shopify Liquid Implementation in Node.js",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -22,12 +22,6 @@ function test(src, dst) {
|
||||
}
|
||||
|
||||
describe('filters', function() {
|
||||
it('should output object', function() {
|
||||
test('{{obj}}', '{"foo":"bar"}');
|
||||
});
|
||||
it('should output array', function() {
|
||||
test('{{arr}}', '[-2,"a"]');
|
||||
});
|
||||
it('should support abs', function() {
|
||||
test('{{ -3 | abs }}', '3');
|
||||
test('{{ arr[0] | abs }}', '2');
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
const chai = require("chai");
|
||||
const expect = chai.expect;
|
||||
|
||||
var liquid = require('..')(),
|
||||
ctx;
|
||||
|
||||
function test(src, dst) {
|
||||
ctx = {
|
||||
date: new Date(),
|
||||
foo: 'bar',
|
||||
arr: [-2, 'a'],
|
||||
obj: {
|
||||
foo: 'bar'
|
||||
},
|
||||
posts: [{
|
||||
category: 'foo'
|
||||
}, {
|
||||
category: 'bar'
|
||||
}]
|
||||
};
|
||||
expect(liquid.render(src, ctx)).to.equal(dst);
|
||||
}
|
||||
|
||||
describe('liquid', function() {
|
||||
it('should output object', function() {
|
||||
test('{{obj}}', '{"foo":"bar"}');
|
||||
});
|
||||
it('should output array', function() {
|
||||
test('{{arr}}', '[-2,"a"]');
|
||||
});
|
||||
});
|
||||
+2
-2
@@ -54,8 +54,8 @@ describe('tags', function() {
|
||||
testThrow('{% if false%}yes', /tag {% if false%} not closed/);
|
||||
test('{%if emptyArray%}a{%endif%}', '');
|
||||
test('{% if 2==3 %}yes{%else%}no{%endif%}', 'no');
|
||||
test('{% if 1==2 and one<two %}a{%endif%}', '');
|
||||
test('{% if false %}yes{%else%}no{%endif%}', 'no');
|
||||
test('{% if 1>=2 and one<two %}a{%endif%}', '');
|
||||
test('{% if one!=two %}yes{%else%}no{%endif%}', 'yes');
|
||||
test('{% if false %}1{%elsif true%}2{%else%}3{%endif%}', '2');
|
||||
test('{%if false%}{%if true%}{%else%}a{%endif%}{%endif%}', '');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user