fix: contains operator does not support Drop, fixes #492

This commit is contained in:
Harttle
2022-04-18 00:43:18 +08:00
parent eec381ec72
commit 9e024ff2bc
3 changed files with 21 additions and 2 deletions
+10 -1
View File
@@ -1,4 +1,4 @@
import { Liquid } from '../..'
import { Liquid, Drop } from '../..'
import { expect, use } from 'chai'
import * as chaiAsPromised from 'chai-as-promised'
import * as sinon from 'sinon'
@@ -232,4 +232,13 @@ describe('Issues', function () {
const html = await engine.parseAndRender(`{% assign a = "x,y,z" | split: ',' -%}{{ a[-1] }} {{ a[-3] }} {{ a[-8] }}`)
expect(html).to.equal('z x ')
})
it('#492 contains operator does not support Drop', async () => {
class TemplateDrop extends Drop {
valueOf () { return 'product' }
}
const engine = new Liquid()
const ctx = { template: new TemplateDrop() }
const html = await engine.parseAndRender(`{% if template contains "product" %}contains{%endif%}`, ctx)
expect(html).to.equal('contains')
})
})