From 18055c88553b96f774277078b9bd437fa79292bf Mon Sep 17 00:00:00 2001 From: Jason Etcovitch Date: Tue, 2 Feb 2021 11:43:19 -0500 Subject: [PATCH] test: add LiquidOptions#operators test --- test/integration/liquid/operators-option.ts | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 test/integration/liquid/operators-option.ts diff --git a/test/integration/liquid/operators-option.ts b/test/integration/liquid/operators-option.ts new file mode 100644 index 000000000..11f04b214 --- /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') + }) +})