feat(Drop): liquid_method_missing and to_s

close #97
This commit is contained in:
harttle
2019-01-28 19:53:04 +08:00
parent f38ea63c14
commit 4dffb27e95
5 changed files with 57 additions and 25 deletions
+18
View File
@@ -63,6 +63,24 @@ describe('render', function () {
const tpl = Template.parseValue('obj')
return expect(render.renderValue(tpl, scope)).to.eventually.equal('{"foo":"foo"}')
})
it('should respect to .toString()', async () => {
const scope = scopeFactory({ obj: { toString: () => 'FOO' } })
const tpl = Template.parseValue('obj')
const str = await render.renderValue(tpl, scope)
return expect(str).to.equal('FOO')
})
it('should respect to .to_s()', async () => {
const scope = scopeFactory({ obj: { to_s: () => 'FOO' } })
const tpl = Template.parseValue('obj')
const str = await render.renderValue(tpl, scope)
return expect(str).to.equal('FOO')
})
it('should respect to .liquid_method_missing()', async () => {
const scope = scopeFactory({ obj: { liquid_method_missing: x => x.toUpperCase() } })
const tpl = Template.parseValue('obj.foo')
const str = await render.renderValue(tpl, scope)
return expect(str).to.equal('FOO')
})
})
describe('.evalValue()', function () {