mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 12:20:40 -07:00
89 lines
2.4 KiB
TypeScript
89 lines
2.4 KiB
TypeScript
import { isTruthy, isFalsy } from '../../../src/render/boolean'
|
|
import { expect } from 'chai'
|
|
|
|
describe('boolean Shopify', 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
|
|
})
|
|
})
|
|
})
|
|
|
|
describe('boolean jsTruthy', async function () {
|
|
const ctx = {
|
|
opts: {
|
|
jsTruthy: true
|
|
}
|
|
}
|
|
|
|
describe('.isFalsy()', async function () {
|
|
it('null is always falsy', function () {
|
|
expect(isFalsy(null, ctx)).to.be.false
|
|
})
|
|
})
|
|
|
|
describe('.isTruthy()', async function () {
|
|
it('true is truthy', function () {
|
|
expect(isTruthy(true, ctx)).to.be.true
|
|
})
|
|
it('false is falsy', function () {
|
|
expect(isTruthy(false, ctx)).to.be.false
|
|
})
|
|
it('null is always falsy', function () {
|
|
expect(isTruthy(null, ctx)).to.be.true
|
|
})
|
|
it('null is always falsy', function () {
|
|
expect(isTruthy(null, ctx)).to.be.false
|
|
})
|
|
it('"foo" is truthy', function () {
|
|
expect(isTruthy('foo', ctx)).to.be.true
|
|
})
|
|
it('"" is falsy', function () {
|
|
expect(isTruthy('', ctx)).to.be.false
|
|
})
|
|
it('0 is falsy', function () {
|
|
expect(isTruthy(0, ctx)).to.be.false
|
|
})
|
|
it('1 is truthy', function () {
|
|
expect(isTruthy(1, ctx)).to.be.true
|
|
})
|
|
it('1.1 is truthy', function () {
|
|
expect(isTruthy(1.1, ctx)).to.be.true
|
|
})
|
|
it('[1] is truthy', function () {
|
|
expect(isTruthy([1], ctx)).to.be.true
|
|
})
|
|
it('[] is falsy', function () {
|
|
expect(isTruthy([], ctx)).to.be.false
|
|
})
|
|
})
|
|
})
|