mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
+28
-16
@@ -1,25 +1,37 @@
|
||||
import { Drop, Liquid } from '../..'
|
||||
|
||||
class SettingsDrop extends Drop {
|
||||
public foo = 'FOO'
|
||||
public bar () {
|
||||
return 'BAR'
|
||||
}
|
||||
public liquidMethodMissing (key: string) {
|
||||
return key.toUpperCase()
|
||||
}
|
||||
}
|
||||
import { Context, Drop, Liquid } from '../..'
|
||||
|
||||
describe('drop', function () {
|
||||
const settings = new SettingsDrop()
|
||||
let engine: Liquid
|
||||
beforeEach(function () {
|
||||
engine = new Liquid()
|
||||
})
|
||||
it('should support liquidMethodMissing', async function () {
|
||||
const src = `{{settings.foo}},{{settings.bar}},{{settings.coo}}`
|
||||
const html = await engine.parseAndRender(src, { settings })
|
||||
return expect(html).toBe('FOO,BAR,COO')
|
||||
|
||||
describe('liquidMethodMissing', () => {
|
||||
it('should support liquidMethodMissing', async function () {
|
||||
class SettingsDrop extends Drop {
|
||||
public foo = 'FOO'
|
||||
public bar () {
|
||||
return 'BAR'
|
||||
}
|
||||
public liquidMethodMissing (key: string) {
|
||||
return key.toUpperCase()
|
||||
}
|
||||
}
|
||||
const src = `{{settings.foo}},{{settings.bar}},{{settings.coo}}`
|
||||
const html = await engine.parseAndRender(src, { settings: new SettingsDrop() })
|
||||
return expect(html).toBe('FOO,BAR,COO')
|
||||
})
|
||||
|
||||
it('should expose context', async function () {
|
||||
class SettingsDrop extends Drop {
|
||||
public liquidMethodMissing (key: string, context: Context) {
|
||||
return key + ':' + context.getSync([key])
|
||||
}
|
||||
}
|
||||
const src = `{{settings.foo}}`
|
||||
const html = await engine.parseAndRender(src, { settings: new SettingsDrop(), foo: 'FOO' })
|
||||
return expect(html).toBe('foo:FOO')
|
||||
})
|
||||
})
|
||||
|
||||
describe('BlandDrop', function () {
|
||||
|
||||
Reference in New Issue
Block a user