|
1 | 1 | import { expect } from 'chai'
|
2 |
| -import { Liquid } from '../..' |
| 2 | +import { Context, Liquid } from '../..' |
3 | 3 |
|
4 | 4 | describe('#evalValue()', function () {
|
5 | 5 | var engine: Liquid
|
6 |
| - beforeEach(() => { engine = new Liquid() }) |
| 6 | + beforeEach(() => { engine = new Liquid({ globals: { foo: 'FOO' } }) }) |
7 | 7 |
|
8 |
| - it('should eval value', async function () { |
9 |
| - const val = await engine.evalValue('true', { opts: {} } as any) |
| 8 | + it('should support boolean', async function () { |
| 9 | + const val = await engine.evalValue('true') |
10 | 10 | expect(val).to.equal(true)
|
11 | 11 | })
|
| 12 | + |
| 13 | + it('should support binary expression with Context', async function () { |
| 14 | + const val = await engine.evalValue('a > b', { a: 1, b: 2 }) |
| 15 | + expect(val).to.equal(false) |
| 16 | + }) |
| 17 | + |
| 18 | + it('should inherit Liquid options', async function () { |
| 19 | + const val = await engine.evalValue('foo') |
| 20 | + expect(val).to.equal('FOO') |
| 21 | + }) |
| 22 | + |
| 23 | + it('should support passing Context', async function () { |
| 24 | + const val = await engine.evalValue('a > b', new Context({ a: 1, b: 2 })) |
| 25 | + expect(val).to.equal(false) |
| 26 | + }) |
| 27 | + |
| 28 | + it('should respect options in passed in Context', async function () { |
| 29 | + const val = await engine.evalValue('foo', new Context({}, { globals: { foo: 'BAR' } } as any)) |
| 30 | + expect(val).to.equal('BAR') |
| 31 | + }) |
12 | 32 | })
|
0 commit comments