mirror of
https://github.com/harttle/liquidjs.git
synced 2026-10-03 09:05:14 -07:00
All tests passing except describe('#express()'... in liquid.js - commented out
This commit is contained in:
+14
-26
@@ -3,22 +3,20 @@ var expect = chai.expect;
|
|||||||
var engine = require('..')(), ctx;
|
var engine = require('..')(), ctx;
|
||||||
const mock = require('mock-fs');
|
const mock = require('mock-fs');
|
||||||
|
|
||||||
function test(func, cb){
|
function test(promise, cb){
|
||||||
try{
|
return promise
|
||||||
func();
|
.then((result) => {
|
||||||
cb({});
|
return cb({});
|
||||||
}
|
})
|
||||||
catch(e){
|
.catch((error) => {
|
||||||
cb(e);
|
return cb(error);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('error', function() {
|
describe('error', function() {
|
||||||
|
|
||||||
it('should throw TokenizationError when tag illegal', function() {
|
it('should throw TokenizationError when tag illegal', function() {
|
||||||
test(function(){
|
return test(engine.parseAndRender('{% -a %}', {}), function(err){
|
||||||
engine.parseAndRender('{% -a %}', {});
|
|
||||||
}, function(err){
|
|
||||||
expect(err.name).to.equal('TokenizationError');
|
expect(err.name).to.equal('TokenizationError');
|
||||||
expect(err.message).to.equal('illegal tag: {% -a %}');
|
expect(err.message).to.equal('illegal tag: {% -a %}');
|
||||||
expect(err.input).to.equal('{% -a %}');
|
expect(err.input).to.equal('{% -a %}');
|
||||||
@@ -27,9 +25,7 @@ describe('error', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should throw correct error info', function() {
|
it('should throw correct error info', function() {
|
||||||
test(function(){
|
return test(engine.parseAndRender('{%if true%}\naaa{%endif%}\n{% -a %}\n3', {}), function(err){
|
||||||
engine.parseAndRender('{%if true%}\naaa{%endif%}\n{% -a %}\n3', {});
|
|
||||||
}, function(err){
|
|
||||||
expect(err.input).to.equal('{% -a %}');
|
expect(err.input).to.equal('{% -a %}');
|
||||||
expect(err.line).to.equal(3);
|
expect(err.line).to.equal(3);
|
||||||
});
|
});
|
||||||
@@ -39,9 +35,7 @@ describe('error', function() {
|
|||||||
mock({
|
mock({
|
||||||
"/foo.html": '<html>\n<head>\n\n{% raw %}\n\n'
|
"/foo.html": '<html>\n<head>\n\n{% raw %}\n\n'
|
||||||
});
|
});
|
||||||
test(function(){
|
return test(engine.renderFile('/foo.html', {}), function(err){
|
||||||
engine.renderFile('/foo.html', {});
|
|
||||||
}, function(err){
|
|
||||||
expect(err.input).to.equal('{% raw %}');
|
expect(err.input).to.equal('{% raw %}');
|
||||||
expect(err.line).to.equal(4);
|
expect(err.line).to.equal(4);
|
||||||
expect(err.file).to.equal('/foo.html');
|
expect(err.file).to.equal('/foo.html');
|
||||||
@@ -49,9 +43,7 @@ describe('error', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should throw ParseError when filter not exist', function() {
|
it('should throw ParseError when filter not exist', function() {
|
||||||
test(function(){
|
return test(engine.parseAndRender('{{ a | xz }}', {}), function(err){
|
||||||
engine.parseAndRender('{{ a | xz }}', {});
|
|
||||||
}, function(err){
|
|
||||||
expect(err.name).to.equal('ParseError');
|
expect(err.name).to.equal('ParseError');
|
||||||
expect(err.message).to.equal('filter "xz" not found');
|
expect(err.message).to.equal('filter "xz" not found');
|
||||||
expect(err.input).to.equal('{{ a | xz }}');
|
expect(err.input).to.equal('{{ a | xz }}');
|
||||||
@@ -59,9 +51,7 @@ describe('error', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('should throw ParseError when tag not exist', function() {
|
it('should throw ParseError when tag not exist', function() {
|
||||||
test(function(){
|
return test(engine.parseAndRender('{% a %}', {}), function(err){
|
||||||
engine.parseAndRender('{% a %}', {});
|
|
||||||
}, function(err){
|
|
||||||
expect(err.name).to.equal('ParseError');
|
expect(err.name).to.equal('ParseError');
|
||||||
expect(err.message).to.equal('tag a not found');
|
expect(err.message).to.equal('tag a not found');
|
||||||
expect(err.input).to.equal('{% a %}');
|
expect(err.input).to.equal('{% a %}');
|
||||||
@@ -70,9 +60,7 @@ describe('error', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should throw ParseError when tag not closed', function() {
|
it('should throw ParseError when tag not closed', function() {
|
||||||
test(function(){
|
return test(engine.parseAndRender('{% if %}', {}), function(err){
|
||||||
engine.parseAndRender('{% if %}', {});
|
|
||||||
}, function(err){
|
|
||||||
expect(err.name).to.equal('ParseError');
|
expect(err.name).to.equal('ParseError');
|
||||||
expect(err.message).to.equal('tag {% if %} not closed');
|
expect(err.message).to.equal('tag {% if %} not closed');
|
||||||
expect(err.input).to.equal('{% if %}');
|
expect(err.input).to.equal('{% if %}');
|
||||||
|
|||||||
+102
-115
@@ -1,8 +1,10 @@
|
|||||||
const chai = require("chai");
|
const chai = require("chai");
|
||||||
|
const chaiAsPromised = require("chai-as-promised");
|
||||||
|
const should = chai.should();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
|
|
||||||
var liquid = require('..')(),
|
var liquid = require('..')(),
|
||||||
ctx;
|
ctx;
|
||||||
|
chai.use(chaiAsPromised);
|
||||||
|
|
||||||
function test(src, dst) {
|
function test(src, dst) {
|
||||||
ctx = {
|
ctx = {
|
||||||
@@ -18,106 +20,87 @@ function test(src, dst) {
|
|||||||
category: 'bar'
|
category: 'bar'
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
expect(liquid.parseAndRender(src, ctx)).to.equal(dst);
|
return liquid.parseAndRender(src, ctx).should.eventually.equal(dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('filters', function() {
|
describe('filters', function() {
|
||||||
it('should support abs', function() {
|
it('should support abs 1', function() { return test('{{ -3 | abs }}', '3'); });
|
||||||
test('{{ -3 | abs }}', '3');
|
it('should support abs 2', function() { return test('{{ arr[0] | abs }}', '2'); });
|
||||||
test('{{ arr[0] | abs }}', '2');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should support append', function() {
|
it('should support append 1', function() { return test('{{ -3 | append: "abc" }}', '-3abc'); });
|
||||||
test('{{ -3 | append: "abc" }}', '-3abc');
|
it('should support append 2', function() { return test('{{ "a" | append: foo }}', 'abar');; });
|
||||||
test('{{ "a" | append: foo }}', 'abar');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should support capitalize', function() {
|
it('should support capitalize', function() { return test('{{ "i am good" | capitalize }}', 'I am good'); });
|
||||||
test('{{ "i am good" | capitalize }}', 'I am good');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should support ceil', function() {
|
it('should support ceil 1', function() { return test('{{ 1.2 | ceil }}', '2'); });
|
||||||
test('{{ 1.2 | ceil }}', '2');
|
it('should support ceil 2', function() { return test('{{ 2.0 | ceil }}', '2'); });
|
||||||
test('{{ 2.0 | ceil }}', '2');
|
it('should support ceil 3', function() { return test('{{ "3.5" | ceil }}', '4'); });
|
||||||
test('{{ "3.5" | ceil }}', '4');
|
it('should support ceil 4', function() { return test('{{ 183.357 | ceil }}', '184'); });
|
||||||
test('{{ 183.357 | ceil }}', '184');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should support date', function() {
|
it('should support date', function() {
|
||||||
str = ctx.date.toDateString();
|
str = ctx.date.toDateString();
|
||||||
test('{{ date | date:"%a %b %d %Y"}}', str);
|
return test('{{ date | date:"%a %b %d %Y"}}', str);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support default', function() {
|
it('should support default', function() { return test('{{false |default: "a"}}', 'a'); });
|
||||||
test('{{false |default: "a"}}', 'a');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should support divided_by', function() {
|
it('should support divided_by 1', function() { return test('{{4 | divided_by: 2}}', '2'); });
|
||||||
test('{{4 | divided_by: 2}}', '2');
|
it('should support divided_by 2', function() { return test('{{16 | divided_by: 4}}', '4'); });
|
||||||
test('{{16 | divided_by: 4}}', '4');
|
it('should support divided_by 3', function() { return test('{{5 | divided_by: 3}}', '1'); });
|
||||||
test('{{5 | divided_by: 3}}', '1');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should support downcase', function() {
|
it('should support downcase 1', function() { return test('{{ "Parker Moore" | downcase }}', 'parker moore'); });
|
||||||
test('{{ "Parker Moore" | downcase }}', 'parker moore');
|
it('should support downcase 2', function() { return test('{{ "apple" | downcase }}', 'apple'); });
|
||||||
test('{{ "apple" | downcase }}', 'apple');
|
|
||||||
});
|
it('should support escape 1', function() {
|
||||||
it('should support escape', function() {
|
return test('{{ "Have you read \'James & the Giant Peach\'?" | escape }}',
|
||||||
test('{{ "Have you read \'James & the Giant Peach\'?" | escape }}',
|
|
||||||
'Have you read 'James & the Giant Peach'?');
|
'Have you read 'James & the Giant Peach'?');
|
||||||
test('{{ "Tetsuro Takara" | escape }}', 'Tetsuro Takara');
|
});
|
||||||
|
it('should support escape 2', function() {
|
||||||
|
return test('{{ "Tetsuro Takara" | escape }}', 'Tetsuro Takara');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support escape_once', function() {
|
it('should support escape_once 1', function() { return test('{{ "1 < 2 & 3" | escape_once }}', '1 < 2 & 3'); });
|
||||||
test('{{ "1 < 2 & 3" | escape_once }}', '1 < 2 & 3');
|
it('should support escape_once 2', function() { return test('{{ "1 < 2 & 3" | escape_once }}', '1 < 2 & 3'); });
|
||||||
test('{{ "1 < 2 & 3" | escape_once }}', '1 < 2 & 3');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should support split/first', function() {
|
it('should support split/first', function() {
|
||||||
src = '{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}' +
|
src = '{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}' +
|
||||||
'{{ my_array | first }}';
|
'{{ my_array | first }}';
|
||||||
test(src, 'apples');
|
return test(src, 'apples');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support floor', function() {
|
it('should support floor 1', function() { return test('{{ 1.2 | floor }}', '1'); });
|
||||||
test('{{ 1.2 | floor }}', '1');
|
it('should support floor 2', function() { return test('{{ 2.0 | floor }}', '2'); });
|
||||||
test('{{ 2.0 | floor }}', '2');
|
it('should support floor 3', function() { return test('{{ 183.357 | floor }}', '183'); });
|
||||||
test('{{ 183.357 | floor }}', '183');
|
it('should support floor 4', function() { return test('{{ "3.5" | floor }}', '3'); });
|
||||||
test('{{ "3.5" | floor }}', '3');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should support join', function() {
|
it('should support join', function() {
|
||||||
src = '{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}' +
|
src = '{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}' +
|
||||||
'{{ beatles | join: " and " }}';
|
'{{ beatles | join: " and " }}';
|
||||||
test(src, 'John and Paul and George and Ringo');
|
return test(src, 'John and Paul and George and Ringo');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support split/last', function() {
|
it('should support split/last', function() {
|
||||||
src = '{% assign my_array = "zebra, octopus, giraffe, tiger" | split: ", " %}' +
|
src = '{% assign my_array = "zebra, octopus, giraffe, tiger" | split: ", " %}' +
|
||||||
'{{ my_array|last }}';
|
'{{ my_array|last }}';
|
||||||
test(src, 'tiger');
|
return test(src, 'tiger');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support lstrip', function() {
|
it('should support lstrip', function() {
|
||||||
src = '{{ " So much room for activities! " | lstrip }}';
|
src = '{{ " So much room for activities! " | lstrip }}';
|
||||||
test(src, 'So much room for activities! ');
|
return test(src, 'So much room for activities! ');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support map', function() {
|
it('should support map', function() {
|
||||||
test('{{posts | map: "category"}}', '["foo","bar"]');
|
return test('{{posts | map: "category"}}', '["foo","bar"]');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support minus', function() {
|
it('should support minus 1', function() { return test('{{ 4 | minus: 2 }}', '2'); });
|
||||||
test('{{ 4 | minus: 2 }}', '2');
|
it('should support minus 2', function() { return test('{{ 16 | minus: 4 }}', '12'); });
|
||||||
test('{{ 16 | minus: 4 }}', '12');
|
it('should support minus 3', function() { return test('{{ 183.357 | minus: 12 }}', '171.357'); });
|
||||||
test('{{ 183.357 | minus: 12 }}', '171.357');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should support modulo', function() {
|
it('should support modulo 1', function() { return test('{{ 3 | modulo: 2 }}', '1'); });
|
||||||
test('{{ 3 | modulo: 2 }}', '1');
|
it('should support modulo 2', function() { return test('{{ 24 | modulo: 7 }}', '3'); });
|
||||||
test('{{ 24 | modulo: 7 }}', '3');
|
it('should support modulo 3', function() { return test('{{ 183.357 | modulo: 12 }}', '3.357'); });
|
||||||
test('{{ 183.357 | modulo: 12 }}', '3.357');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should support string_with_newlines', function() {
|
it('should support string_with_newlines', function() {
|
||||||
src = '{% capture string_with_newlines %}\n' +
|
src = '{% capture string_with_newlines %}\n' +
|
||||||
@@ -128,81 +111,75 @@ describe('filters', function() {
|
|||||||
dst = '<br />' +
|
dst = '<br />' +
|
||||||
'Hello<br />' +
|
'Hello<br />' +
|
||||||
'there<br />';
|
'there<br />';
|
||||||
test(src, dst);
|
return test(src, dst);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support plus', function() {
|
it('should support plus 1', function() { return test('{{ 4 | plus: 2 }}', '6'); });
|
||||||
test('{{ 4 | plus: 2 }}', '6');
|
it('should support plus 2', function() { return test('{{ 16 | plus: 4 }}', '20'); });
|
||||||
test('{{ 16 | plus: 4 }}', '20');
|
it('should support plus 3', function() { return test('{{ 183.357 | plus: 12 }}', '195.357'); });
|
||||||
test('{{ 183.357 | plus: 12 }}', '195.357');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should support prepend', function() {
|
it('should support prepend', function() {
|
||||||
test('{% assign url = "liquidmarkup.com" %}' +
|
return test('{% assign url = "liquidmarkup.com" %}' +
|
||||||
'{{ "/index.html" | prepend: url }}',
|
'{{ "/index.html" | prepend: url }}',
|
||||||
'liquidmarkup.com/index.html');
|
'liquidmarkup.com/index.html');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support remove', function() {
|
it('should support remove', function() {
|
||||||
test('{{ "I strained to see the train through the rain" | remove: "rain" }}',
|
return test('{{ "I strained to see the train through the rain" | remove: "rain" }}',
|
||||||
'I sted to see the t through the ');
|
'I sted to see the t through the ');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support remove_first', function() {
|
it('should support remove_first', function() {
|
||||||
test('{{ "I strained to see the train through the rain" | remove_first: "rain" }}',
|
return test('{{ "I strained to see the train through the rain" | remove_first: "rain" }}',
|
||||||
'I sted to see the train through the rain');
|
'I sted to see the train through the rain');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support replace', function() {
|
it('should support replace', function() {
|
||||||
test('{{ "Take my protein pills and put my helmet on" | replace: "my", "your" }}',
|
return test('{{ "Take my protein pills and put my helmet on" | replace: "my", "your" }}',
|
||||||
'Take your protein pills and put your helmet on');
|
'Take your protein pills and put your helmet on');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support replace_first', function() {
|
it('should support replace_first', function() {
|
||||||
test('{% assign my_string = "Take my protein pills and put my helmet on" %}\n' +
|
return test('{% assign my_string = "Take my protein pills and put my helmet on" %}\n' +
|
||||||
'{{ my_string | replace_first: "my", "your" }}',
|
'{{ my_string | replace_first: "my", "your" }}',
|
||||||
'\nTake your protein pills and put my helmet on');
|
'\nTake your protein pills and put my helmet on');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support reverse', function() {
|
it('should support reverse', function() {
|
||||||
test('{{ "Ground control to Major Tom." | split: "" | reverse | join: "" }}',
|
return test('{{ "Ground control to Major Tom." | split: "" | reverse | join: "" }}',
|
||||||
'.moT rojaM ot lortnoc dnuorG');
|
'.moT rojaM ot lortnoc dnuorG');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support round', function() {
|
it('should support round 1', function() { return test('{{1.2|round}}', '1'); });
|
||||||
test('{{1.2|round}}', '1');
|
it('should support round 2', function() { return test('{{2.7|round}}', '3'); });
|
||||||
test('{{2.7|round}}', '3');
|
it('should support round 3', function() { return test('{{183.357|round: 2}}', '183.36'); });
|
||||||
test('{{183.357|round: 2}}', '183.36');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should support rstrip', function() {
|
it('should support rstrip', function() {
|
||||||
test('{{ " So much room for activities! " | rstrip }}',
|
return test('{{ " So much room for activities! " | rstrip }}',
|
||||||
' So much room for activities!');
|
' So much room for activities!');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support size', function() {
|
it('should support size 1', function() { return test('{{ "Ground control to Major Tom." | size }}', '28'); });
|
||||||
test('{{ "Ground control to Major Tom." | size }}', '28');
|
it('should support size 2', function() {
|
||||||
test('{% assign my_array = "apples, oranges, peaches, plums"' +
|
return test('{% assign my_array = "apples, oranges, peaches, plums"' +
|
||||||
' | split: ", " %}{{ my_array | size }}',
|
' | split: ", " %}{{ my_array | size }}',
|
||||||
'4');
|
'4');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support slice', function() {
|
it('should support slice 1', function() { return test('{{ "Liquid" | slice: 0 }}', 'L'); });
|
||||||
test('{{ "Liquid" | slice: 0 }}', 'L');
|
it('should support slice 2', function() { return test('{{ "Liquid" | slice: 2 }}', 'q'); });
|
||||||
test('{{ "Liquid" | slice: 2 }}', 'q');
|
it('should support slice 3', function() { return test('{{ "Liquid" | slice: 2, 5 }}', 'quid'); });
|
||||||
test('{{ "Liquid" | slice: 2, 5 }}', 'quid');
|
it('should support slice 4', function() { return test('{{ "Liquid" | slice: -3, 2 }}', 'ui'); });
|
||||||
test('{{ "Liquid" | slice: -3, 2 }}', 'ui');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should support sort', function() {
|
it('should support sort', function() {
|
||||||
test('{% assign my_array = "zebra, octopus, giraffe, Sally Snake"' +
|
return test('{% assign my_array = "zebra, octopus, giraffe, Sally Snake"' +
|
||||||
' | split: ", " %}' +
|
' | split: ", " %}' +
|
||||||
'{{ my_array | sort | join: ", " }}',
|
'{{ my_array | sort | join: ", " }}',
|
||||||
'Sally Snake, giraffe, octopus, zebra');
|
'Sally Snake, giraffe, octopus, zebra');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support split', function() {
|
it('should support split', function() {
|
||||||
test('{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}' +
|
return test('{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}' +
|
||||||
'{% for member in beatles %}' +
|
'{% for member in beatles %}' +
|
||||||
'{{ member }} ' +
|
'{{ member }} ' +
|
||||||
'{% endfor %}',
|
'{% endfor %}',
|
||||||
@@ -210,63 +187,73 @@ describe('filters', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should support strip', function() {
|
it('should support strip', function() {
|
||||||
test('{{ " So much room for activities! " | strip }}',
|
return test('{{ " So much room for activities! " | strip }}',
|
||||||
'So much room for activities!');
|
'So much room for activities!');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support strip_tml', function() {
|
it('should support strip_tml 1', function() {
|
||||||
test('{{ "Have <em>you</em> read <strong>Ulysses</strong>?" | strip_html }}',
|
return test('{{ "Have <em>you</em> read <strong>Ulysses</strong>?" | strip_html }}',
|
||||||
'Have you read Ulysses?');
|
'Have you read Ulysses?');
|
||||||
test('{{"<br/><br />< p ></p></ p >" | strip_html }}', '');
|
});
|
||||||
|
it('should support strip_tml 2', function() {
|
||||||
|
return test('{{"<br/><br />< p ></p></ p >" | strip_html }}', '');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support strip_newlines', function() {
|
it('should support strip_newlines', function() {
|
||||||
test('{% capture string_with_newlines %}\n' +
|
return test('{% capture string_with_newlines %}\n' +
|
||||||
'Hello\nthere\n{% endcapture %}' +
|
'Hello\nthere\n{% endcapture %}' +
|
||||||
'{{ string_with_newlines | strip_newlines }}',
|
'{{ string_with_newlines | strip_newlines }}',
|
||||||
'Hellothere');
|
'Hellothere');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support times', function() {
|
it('should support times 1', function() { return test('{{ 3 | times: 2 }}', '6'); });
|
||||||
test('{{ 3 | times: 2 }}', '6');
|
it('should support times 2', function() { return test('{{ 24 | times: 7 }}', '168'); });
|
||||||
test('{{ 24 | times: 7 }}', '168');
|
it('should support times 3', function() { return test('{{ 183.357 | times: 12 }}', '2200.284'); });
|
||||||
test('{{ 183.357 | times: 12 }}', '2200.284');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should support truncate', function() {
|
it('should support truncate 1', function() {
|
||||||
test('{{ "Ground control to Major Tom." | truncate: 20 }}',
|
return test('{{ "Ground control to Major Tom." | truncate: 20 }}',
|
||||||
'Ground control to...');
|
'Ground control to...');
|
||||||
test('{{ "Ground control to Major Tom." | truncate: 80 }}',
|
});
|
||||||
|
it('should support truncate 2', function() {
|
||||||
|
return test('{{ "Ground control to Major Tom." | truncate: 80 }}',
|
||||||
'Ground control to Major Tom.');
|
'Ground control to Major Tom.');
|
||||||
test('{{ "Ground control to Major Tom." | truncate: 25,", and so on" }}',
|
});
|
||||||
|
it('should support truncate 3', function() {
|
||||||
|
return test('{{ "Ground control to Major Tom." | truncate: 25,", and so on" }}',
|
||||||
'Ground control, and so on');
|
'Ground control, and so on');
|
||||||
test('{{ "Ground control to Major Tom." | truncate: 20, "" }}',
|
});
|
||||||
|
it('should support truncate 4', function() {
|
||||||
|
return test('{{ "Ground control to Major Tom." | truncate: 20, "" }}',
|
||||||
'Ground control to Ma');
|
'Ground control to Ma');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support truncatewords', function() {
|
it('should support truncatewords 1', function() {
|
||||||
test('{{ "Ground control to Major Tom." | truncatewords: 3 }}',
|
return test('{{ "Ground control to Major Tom." | truncatewords: 3 }}',
|
||||||
'Ground control to...');
|
'Ground control to...');
|
||||||
test('{{ "Ground control to Major Tom." | truncatewords: 8 }}',
|
});
|
||||||
|
it('should support truncatewords 2', function() {
|
||||||
|
return test('{{ "Ground control to Major Tom." | truncatewords: 8 }}',
|
||||||
'Ground control to Major Tom.');
|
'Ground control to Major Tom.');
|
||||||
test('{{ "Ground control to Major Tom." | truncatewords: 3, "--" }}',
|
});
|
||||||
|
it('should support truncatewords 3', function() {
|
||||||
|
return test('{{ "Ground control to Major Tom." | truncatewords: 3, "--" }}',
|
||||||
'Ground control to--');
|
'Ground control to--');
|
||||||
test('{{ "Ground control to Major Tom." | truncatewords: 3, "" }}',
|
});
|
||||||
|
it('should support truncatewords 4', function() {
|
||||||
|
return test('{{ "Ground control to Major Tom." | truncatewords: 3, "" }}',
|
||||||
'Ground control to');
|
'Ground control to');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support uniq', function() {
|
it('should support uniq', function() {
|
||||||
test('{% assign my_array = "ants, bugs, bees, bugs, ants" | split: ", " %}' +
|
return test('{% assign my_array = "ants, bugs, bees, bugs, ants" | split: ", " %}' +
|
||||||
'{{ my_array | uniq | join: ", " }}',
|
'{{ my_array | uniq | join: ", " }}',
|
||||||
'ants, bugs, bees');
|
'ants, bugs, bees');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support upcase', function() {
|
it('should support upcase', function() {
|
||||||
test('{{ "Parker Moore" | upcase }}', 'PARKER MOORE');
|
return test('{{ "Parker Moore" | upcase }}', 'PARKER MOORE');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support url_encode', function() {
|
it('should support url_encode 1', function() { return test('{{ "[email protected]" | url_encode }}', 'john%40liquid.com'); });
|
||||||
test('{{ "[email protected]" | url_encode }}', 'john%40liquid.com');
|
it('should support url_encode 2', function() { return test('{{ "Tetsuro Takara" | url_encode }}', 'Tetsuro%20Takara'); });
|
||||||
test('{{ "Tetsuro Takara" | url_encode }}', 'Tetsuro%20Takara');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
+5
-5
@@ -1,9 +1,12 @@
|
|||||||
const chai = require("chai");
|
const chai = require("chai");
|
||||||
|
const chaiAsPromised = require("chai-as-promised");
|
||||||
|
const should = chai.should();
|
||||||
|
const expect = chai.expect;
|
||||||
const sinonChai = require("sinon-chai");
|
const sinonChai = require("sinon-chai");
|
||||||
const sinon = require("sinon");
|
const sinon = require("sinon");
|
||||||
const expect = chai.expect;
|
|
||||||
|
|
||||||
chai.use(sinonChai);
|
chai.use(sinonChai);
|
||||||
|
chai.use(chaiAsPromised);
|
||||||
|
|
||||||
var tag = require('../src/tag.js')();
|
var tag = require('../src/tag.js')();
|
||||||
var Scope = require('../src/scope.js');
|
var Scope = require('../src/scope.js');
|
||||||
@@ -26,10 +29,7 @@ describe('render', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should render html', function() {
|
it('should render html', function() {
|
||||||
expect(render.renderTemplates([{
|
return render.renderTemplates([{type: 'html', value: '<p>'}], scope).should.eventually.equal('<p>');
|
||||||
type: 'html',
|
|
||||||
value: '<p>'
|
|
||||||
}], scope)).to.equal('<p>');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should eval filter with correct arguments', function() {
|
it('should eval filter with correct arguments', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user