mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 21:00:40 -07:00
+22
-15
@@ -1,38 +1,45 @@
|
||||
import { isTruthy, isFalsy } from '../../../src/render/boolean'
|
||||
import { Context } from '../../../src/context/context'
|
||||
import { expect } from 'chai'
|
||||
|
||||
describe('boolean Shopify', async function () {
|
||||
describe('.isTruthy()', async function () {
|
||||
const ctx = {
|
||||
opts: {
|
||||
jsTruthy: false
|
||||
}
|
||||
} as unknown as Context
|
||||
//
|
||||
// Spec: https://shopify.github.io/liquid/basics/truthy-and-falsy/
|
||||
it('true is truthy', function () {
|
||||
expect(isTruthy(true)).to.be.true
|
||||
expect(isTruthy(true, ctx)).to.be.true
|
||||
})
|
||||
it('false is falsy', function () {
|
||||
expect(isTruthy(false)).to.be.false
|
||||
expect(isTruthy(false, ctx)).to.be.false
|
||||
})
|
||||
it('null is falsy', function () {
|
||||
expect(isTruthy(null)).to.be.false
|
||||
expect(isTruthy(null, ctx)).to.be.false
|
||||
})
|
||||
it('"foo" is truthy', function () {
|
||||
expect(isTruthy('foo')).to.be.true
|
||||
expect(isTruthy('foo', ctx)).to.be.true
|
||||
})
|
||||
it('"" is truthy', function () {
|
||||
expect(isTruthy('')).to.be.true
|
||||
expect(isTruthy('', ctx)).to.be.true
|
||||
})
|
||||
it('0 is truthy', function () {
|
||||
expect(isTruthy(0)).to.be.true
|
||||
expect(isTruthy(0, ctx)).to.be.true
|
||||
})
|
||||
it('1 is truthy', function () {
|
||||
expect(isTruthy(1)).to.be.true
|
||||
expect(isTruthy(1, ctx)).to.be.true
|
||||
})
|
||||
it('1.1 is truthy', function () {
|
||||
expect(isTruthy(1.1)).to.be.true
|
||||
expect(isTruthy(1.1, ctx)).to.be.true
|
||||
})
|
||||
it('[1] is truthy', function () {
|
||||
expect(isTruthy([1])).to.be.true
|
||||
expect(isTruthy([1], ctx)).to.be.true
|
||||
})
|
||||
it('[] is truthy', function () {
|
||||
expect(isTruthy([])).to.be.true
|
||||
expect(isTruthy([], ctx)).to.be.true
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -42,11 +49,11 @@ describe('boolean jsTruthy', async function () {
|
||||
opts: {
|
||||
jsTruthy: true
|
||||
}
|
||||
}
|
||||
} as unknown as Context
|
||||
|
||||
describe('.isFalsy()', async function () {
|
||||
it('null is always falsy', function () {
|
||||
expect(isFalsy(null, ctx)).to.be.false
|
||||
expect(isFalsy(null, ctx)).to.be.true
|
||||
})
|
||||
})
|
||||
|
||||
@@ -58,7 +65,7 @@ describe('boolean jsTruthy', async function () {
|
||||
expect(isTruthy(false, ctx)).to.be.false
|
||||
})
|
||||
it('null is always falsy', function () {
|
||||
expect(isTruthy(null, ctx)).to.be.true
|
||||
expect(isTruthy(null, ctx)).to.be.false
|
||||
})
|
||||
it('null is always falsy', function () {
|
||||
expect(isTruthy(null, ctx)).to.be.false
|
||||
@@ -81,8 +88,8 @@ describe('boolean jsTruthy', async function () {
|
||||
it('[1] is truthy', function () {
|
||||
expect(isTruthy([1], ctx)).to.be.true
|
||||
})
|
||||
it('[] is falsy', function () {
|
||||
expect(isTruthy([], ctx)).to.be.false
|
||||
it('[] is truthy', function () {
|
||||
expect(isTruthy([], ctx)).to.be.true
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user