mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
fix: Rely on equal for computing contains (#668)
* fix: rely on equal for computing contains This change allows contains to be computed using the toValue of the items in the array. Before this change if I had an array of "Drop" `contains` would not match against the value. * Apply suggestions from code review Co-authored-by: Jun Yang <[email protected]> --------- Co-authored-by: Jun Yang <[email protected]>
This commit is contained in:
@@ -147,6 +147,20 @@ describe('Expression', function () {
|
||||
const ctx = new Context({ x: 'XXX', X: new TemplateDrop() })
|
||||
expect(await toPromise(create('x contains X').evaluate(ctx, false))).toBe(true)
|
||||
})
|
||||
it('should support Drops for "x contains "x"" when x is an array', async () => {
|
||||
class TemplateDrop extends Drop {
|
||||
valueOf () { return 'X' }
|
||||
}
|
||||
const ctx = new Context({ x: [new TemplateDrop()], X: 'X' })
|
||||
expect(await toPromise(create('x contains X').evaluate(ctx, false))).toBe(true)
|
||||
})
|
||||
it('should support Drops for "x contains "x"" when x is an array on both operands', async () => {
|
||||
class TemplateDrop extends Drop {
|
||||
valueOf () { return 'X' }
|
||||
}
|
||||
const ctx = new Context({ x: [new TemplateDrop()], X: new TemplateDrop() })
|
||||
expect(await toPromise(create('x contains X').evaluate(ctx, false))).toBe(true)
|
||||
})
|
||||
it('should support value and !=', async function () {
|
||||
const ctx = new Context({ empty: '' })
|
||||
expect(await toPromise(create('empty and empty != ""').evaluate(ctx, false))).toBe(false)
|
||||
|
||||
Reference in New Issue
Block a user