test: add LiquidOptions#operators test

This commit is contained in:
Jason Etcovitch
2021-02-04 09:11:28 +08:00
committed by Jun Yang
parent 6a7c280f04
commit 18055c8855
@@ -0,0 +1,25 @@
import { expect } from 'chai'
import { Liquid, Operators } from '../../../src/liquid'
describe('LiquidOptions#operators', function () {
let engine: Liquid
beforeEach(function () {
engine = new Liquid({
operators: {
...Operators,
isFooBar: (l, r) => l === 'foo' && r === 'bar'
}
})
})
it('should evaluate the default operators', async function () {
const result = await engine.parseAndRender('{% if "foo" == "foo" %}True{% endif %}')
expect(result).to.equal('True')
})
it('should evaluate a custom operator', async function () {
const result = await engine.parseAndRender('{% if "foo" isFooBar "bar" %}True{% endif %}')
expect(result).to.equal('True')
})
})