mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 12:20:40 -07:00
28 lines
901 B
TypeScript
28 lines
901 B
TypeScript
import { expect } from 'chai'
|
|
import { Liquid, defaultOperators } from '../../../src/liquid'
|
|
|
|
describe('LiquidOptions#operators', function () {
|
|
let engine: Liquid
|
|
|
|
beforeEach(function () {
|
|
engine = new Liquid({
|
|
operators: {
|
|
...defaultOperators,
|
|
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 first = await engine.parseAndRender('{% if "foo" isFooBar "bar" %}True{% else %}False{% endif %}')
|
|
expect(first).to.equal('True')
|
|
const second = await engine.parseAndRender('{% if "foo" isFooBar "foo" %}True{% else %}False{% endif %}')
|
|
expect(second).to.equal('False')
|
|
})
|
|
})
|