mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
fix: for tag not respecting Drop#valueOf(), fixes #515
This commit is contained in:
@@ -324,8 +324,7 @@ describe('tags/for', function () {
|
||||
yield 'b'
|
||||
yield 'c'
|
||||
}
|
||||
|
||||
public valueOf (): string {
|
||||
toString () {
|
||||
return 'MockIterableDrop'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,4 +61,15 @@ describe('drop/drop', function () {
|
||||
const html = await liquid.parseAndRender(`{{obj.foo}}`, { obj: new PromiseDrop() })
|
||||
expect(html).to.equal('FOO')
|
||||
})
|
||||
it('should respect valueOf', async () => {
|
||||
class CustomDrop extends Drop {
|
||||
prop = 'not enumerable'
|
||||
valueOf () {
|
||||
return ['foo', 'bar']
|
||||
}
|
||||
}
|
||||
const tpl = '{{drop}}: {% for field in drop %}{{ field }};{% endfor %}'
|
||||
const html = await liquid.parseAndRender(tpl, { drop: new CustomDrop() })
|
||||
expect(html).to.equal('foobar: foo;bar;')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
import { expect } from 'chai'
|
||||
import { Drop } from '../../../src/drop/drop'
|
||||
|
||||
describe('drop/drop', function () {
|
||||
class CustomDrop extends Drop { }
|
||||
|
||||
it('.valueOf() should return undefined by default', async function () {
|
||||
expect(new CustomDrop().valueOf()).to.be.undefined
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user