feat: passing liquid to FilterImpl, closes #277

This commit is contained in:
harttle
2020-12-08 00:17:27 +08:00
parent 2bbf50171b
commit f9f595f0f4
11 changed files with 52 additions and 25 deletions
+6 -5
View File
@@ -9,9 +9,10 @@ const expect = chai.expect
describe('Output', function () {
const emitter: any = { write: (html: string) => (emitter.html += html), html: '' }
const liquid = {} as any
let filters: FilterMap
beforeEach(function () {
filters = new FilterMap(false)
filters = new FilterMap(false, liquid)
emitter.html = ''
})
@@ -19,25 +20,25 @@ describe('Output', function () {
const scope = new Context({
foo: { obj: { arr: ['a', 2] } }
})
const output = new Output({ content: 'foo' } as OutputToken, filters)
const output = new Output({ content: 'foo' } as OutputToken, filters, liquid)
await toThenable(output.render(scope, emitter))
return expect(emitter.html).to.equal('[object Object]')
})
it('should skip function property', async function () {
const scope = new Context({ obj: { foo: 'foo', bar: (x: any) => x } })
const output = new Output({ content: 'obj' } as OutputToken, filters)
const output = new Output({ content: 'obj' } as OutputToken, filters, liquid)
await toThenable(output.render(scope, emitter))
return expect(emitter.html).to.equal('[object Object]')
})
it('should respect to .toString()', async () => {
const scope = new Context({ obj: { toString: () => 'FOO' } })
const output = new Output({ content: 'obj' } as OutputToken, filters)
const output = new Output({ content: 'obj' } as OutputToken, filters, liquid)
await toThenable(output.render(scope, emitter))
return expect(emitter.html).to.equal('FOO')
})
it('should respect to .toString()', async () => {
const scope = new Context({ obj: { toString: () => 'FOO' } })
const output = new Output({ content: 'obj' } as OutputToken, filters)
const output = new Output({ content: 'obj' } as OutputToken, filters, liquid)
await toThenable(output.render(scope, emitter))
return expect(emitter.html).to.equal('FOO')
})