refactor: rewrite expression evaluation, fix #130

This commit is contained in:
harttle
2019-08-26 10:15:43 -05:00
committed by Jun Yang
parent 538610e169
commit 76019e9e18
31 changed files with 407 additions and 246 deletions
+38
View File
@@ -0,0 +1,38 @@
import { isTruthy } from '../../../src/render/boolean'
import { expect } from 'chai'
describe('boolean', async function () {
describe('.isTruthy()', async function () {
// Spec: https://shopify.github.io/liquid/basics/truthy-and-falsy/
it('true is truthy', function () {
expect(isTruthy(true)).to.be.true
})
it('false is falsy', function () {
expect(isTruthy(false)).to.be.false
})
it('null is falsy', function () {
expect(isTruthy(null)).to.be.false
})
it('"foo" is truthy', function () {
expect(isTruthy('foo')).to.be.true
})
it('"" is truthy', function () {
expect(isTruthy('')).to.be.true
})
it('0 is truthy', function () {
expect(isTruthy(0)).to.be.true
})
it('1 is truthy', function () {
expect(isTruthy(1)).to.be.true
})
it('1.1 is truthy', function () {
expect(isTruthy(1.1)).to.be.true
})
it('[1] is truthy', function () {
expect(isTruthy([1])).to.be.true
})
it('[] is truthy', function () {
expect(isTruthy([])).to.be.true
})
})
})