mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
feat: passing liquid to FilterImpl, closes #277
This commit is contained in:
@@ -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')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user