diff --git a/test/integration/liquid/operators-option.ts b/test/integration/liquid/operators-option.ts new file mode 100644 index 0000000000..11f04b2148 --- /dev/null +++ b/test/integration/liquid/operators-option.ts @@ -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') + }) +})