mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-18 22:10:41 -07:00
fix: [expression] apply value equal for arrays, #589
This commit is contained in:
@@ -400,4 +400,14 @@ describe('Issues', function () {
|
||||
const html = await engine.parseAndRender(template, { str })
|
||||
expect(html).to.match(/^\s*$/)
|
||||
})
|
||||
it('#589 Arrays should compare values', async() => {
|
||||
const engine = new Liquid()
|
||||
const template = `
|
||||
{% assign people1 = "alice, bob, carol" | split: ", " -%}
|
||||
{% assign people2 = "alice, bob, carol" | split: ", " -%}
|
||||
{% if people1 == people2 %}true{%else%}false{% endif %}
|
||||
`;
|
||||
const html = await engine.parseAndRender(template)
|
||||
expect(html).to.contain('true')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -53,6 +53,15 @@ describe('Expression', function () {
|
||||
it('should return false for "1==2"', async () => {
|
||||
expect(await toPromise(create('1==2').evaluate(ctx, false))).to.equal(false)
|
||||
})
|
||||
it('should apply deep equal for arrays', async () => {
|
||||
const ctx = new Context({
|
||||
arr1: [1, 2],
|
||||
arr2: [1, 2],
|
||||
arr3: [1, 2, 3],
|
||||
})
|
||||
expect(await toPromise(create('arr1==arr2').evaluate(ctx, false))).to.equal(true)
|
||||
expect(await toPromise(create('arr1==arr3').evaluate(ctx, false))).to.equal(false)
|
||||
})
|
||||
it('should return true for "1<2"', async () => {
|
||||
expect(await toPromise(create('1<2').evaluate(ctx, false))).to.equal(true)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user