mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 12:50:38 -07:00
test: cases for async variables
This commit is contained in:
@@ -142,4 +142,10 @@ describe('tags/if', function () {
|
||||
const html = liquid.parseAndRenderSync(src, scope)
|
||||
return expect(html).to.equal('true')
|
||||
})
|
||||
it('should support async variables', async () => {
|
||||
const src = `{%if var == 'var' %}success{%endif%}`
|
||||
const scope = { 'var': Promise.resolve('var') }
|
||||
const html = await liquid.parseAndRender(src, scope)
|
||||
return expect(html).to.equal('success')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -52,6 +52,11 @@ describe('Liquid', function () {
|
||||
const src = '{{ foo }}'
|
||||
return expect(engine.parseAndRender(src, {}, { strictVariables: true })).rejectedWith(/undefined variable/)
|
||||
})
|
||||
it('should support async variables in output', async () => {
|
||||
const src = '{{ foo }}'
|
||||
const html = await engine.parseAndRender(src, { foo: Promise.resolve('FOO') })
|
||||
expect(html).to.equal('FOO')
|
||||
})
|
||||
})
|
||||
describe('#express()', function () {
|
||||
const liquid = new Liquid({ root: '/root' })
|
||||
|
||||
Reference in New Issue
Block a user