mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
tests for truthy
This commit is contained in:
@@ -5,6 +5,7 @@ var Scope = require('../src/scope.js');
|
||||
|
||||
var evalExp = syntax.evalExp;
|
||||
var evalValue = syntax.evalValue;
|
||||
var isTruthy = syntax.isTruthy;
|
||||
|
||||
describe('expression', function() {
|
||||
var scope;
|
||||
@@ -30,6 +31,20 @@ describe('expression', function() {
|
||||
expect(evalValue('x', scope)).to.equal('XXX');
|
||||
});
|
||||
|
||||
describe('.isTruthy()', function() {
|
||||
// Spec: https://shopify.github.io/liquid/basics/truthy-and-falsy/
|
||||
expect(isTruthy(true)).to.be.true;
|
||||
expect(isTruthy(false)).to.be.false;
|
||||
expect(isTruthy(null)).to.be.false;
|
||||
expect(isTruthy('foo')).to.be.true;
|
||||
expect(isTruthy('')).to.be.true;
|
||||
expect(isTruthy(0)).to.be.true;
|
||||
expect(isTruthy(1)).to.be.true;
|
||||
expect(isTruthy(1.1)).to.be.true;
|
||||
expect(isTruthy([1])).to.be.true;
|
||||
expect(isTruthy([])).to.be.true;
|
||||
})
|
||||
|
||||
describe('.evalExp()', function() {
|
||||
|
||||
it('should throw when scope undefined', function() {
|
||||
|
||||
Reference in New Issue
Block a user