mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 12:20:40 -07:00
test: cases for async variables
This commit is contained in:
Generated
+3
-3
@@ -2662,9 +2662,9 @@
|
||||
}
|
||||
},
|
||||
"caniuse-lite": {
|
||||
"version": "1.0.30001312",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001312.tgz",
|
||||
"integrity": "sha512-Wiz1Psk2MEK0pX3rUzWaunLTZzqS2JYZFzNKqAiJGiuxIjRPLgV6+VDPOg6lQOUxmDwhTlh198JsTTi8Hzw6aQ==",
|
||||
"version": "1.0.30001335",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001335.tgz",
|
||||
"integrity": "sha512-ddP1Tgm7z2iIxu6QTtbZUv6HJxSaV/PZeSrWFZtbY4JZ69tOeNhBCl3HyRQgeNZKE5AOn1kpV7fhljigy0Ty3w==",
|
||||
"dev": true
|
||||
},
|
||||
"cardinal": {
|
||||
|
||||
@@ -25,9 +25,9 @@ export class Expression {
|
||||
const operands: any[] = []
|
||||
for (const token of this.postfix) {
|
||||
if (TypeGuards.isOperatorToken(token)) {
|
||||
const r = yield operands.pop()
|
||||
const l = yield operands.pop()
|
||||
const result = evalOperatorToken(ctx.opts.operators, token, l, r, ctx)
|
||||
const r = operands.pop()
|
||||
const l = operands.pop()
|
||||
const result = yield evalOperatorToken(ctx.opts.operators, token, l, r, ctx)
|
||||
operands.push(result)
|
||||
} else {
|
||||
operands.push(yield evalToken(token, ctx, lenient && this.postfix.length === 1))
|
||||
|
||||
@@ -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