fix: expression support Drop.valueOf, fixes #522

This commit is contained in:
Harttle
2022-07-21 01:21:58 +08:00
committed by Harttle
parent 66eb3b842a
commit 4ad383d9be
2 changed files with 20 additions and 8 deletions
+12
View File
@@ -72,4 +72,16 @@ describe('drop/drop', function () {
const html = await liquid.parseAndRender(tpl, { drop: new CustomDrop() })
expect(html).to.equal('foobar: foo;bar;')
})
it('should support valueOf in == expression', async () => {
class AddressDrop extends Drop {
valueOf () {
return 'test'
}
}
const address = new AddressDrop()
const customer = { default_address: new AddressDrop() }
const tpl = `{% if address == customer.default_address %}{{address}}{% endif %}`
const html = await liquid.parseAndRender(tpl, { address, customer })
expect(html).to.equal('test')
})
})