mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 12:20:40 -07:00
feat: pass context to filters
This commit is contained in:
@@ -22,12 +22,18 @@ describe('filter', function () {
|
||||
expect(await new Filter('undefined', [], false).render('foo', ctx)).to.equal('foo')
|
||||
})
|
||||
|
||||
it('should call filter impl with corrct arguments', async function () {
|
||||
it('should call filter impl with correct arguments', async function () {
|
||||
const spy = sinon.spy()
|
||||
Filter.register('foo', spy)
|
||||
await new Filter('foo', ['33'], false).render('foo', ctx)
|
||||
expect(spy).to.have.been.calledWith('foo', 33)
|
||||
})
|
||||
it('should call filter impl with correct this arg', async function () {
|
||||
const spy = sinon.spy()
|
||||
Filter.register('foo', spy)
|
||||
await new Filter('foo', ['33'], false).render('foo', ctx)
|
||||
expect(spy).to.have.been.calledOn(sinon.match.has('context', ctx))
|
||||
})
|
||||
it('should render a simple filter', async function () {
|
||||
Filter.register('upcase', x => x.toUpperCase())
|
||||
expect(await new Filter('upcase', [], false).render('foo', ctx)).to.equal('FOO')
|
||||
|
||||
Reference in New Issue
Block a user