fix: use drop valueOf when evaluated as condition (#705)

This commit is contained in:
Adam Tanner
2024-06-05 08:28:21 +08:00
committed by GitHub
parent 513940dfa7
commit a7da93ff0f
3 changed files with 27 additions and 2 deletions
+11 -1
View File
@@ -1,5 +1,6 @@
import { isTruthy, isFalsy } from './boolean'
import { Context } from '../context'
import { Drop } from '..'
describe('boolean Shopify', function () {
describe('.isTruthy()', function () {
@@ -8,7 +9,13 @@ describe('boolean Shopify', function () {
jsTruthy: false
}
} as unknown as Context
//
class BooleanDrop extends Drop {
public valueOf () {
return false
}
}
// Spec: https://shopify.github.io/liquid/basics/truthy-and-falsy/
it('true is truthy', function () {
expect(isTruthy(true, ctx)).toBeTruthy()
@@ -40,6 +47,9 @@ describe('boolean Shopify', function () {
it('[] is truthy', function () {
expect(isTruthy([], ctx)).toBeTruthy()
})
it('drop valueOf determines truthy', function () {
expect(isTruthy(new BooleanDrop(), ctx)).toBeFalsy()
})
})
})