-
-
Notifications
You must be signed in to change notification settings - Fork 273
Expand file tree
/
Copy pathdrop.spec.ts
More file actions
48 lines (44 loc) · 1.48 KB
/
drop.spec.ts
File metadata and controls
48 lines (44 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { Context, Drop, Liquid } from '../..'
describe('drop', function () {
let engine: Liquid
beforeEach(function () {
engine = new Liquid()
})
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 () {
it('should test blank strings', async function () {
const src = `
{% unless settings.fpHeading == blank %}
<h1>{{ settings.fpHeading }}</h1>
{% endunless %}`
var ctx = { settings: { fpHeading: '' } }
const html = await engine.parseAndRender(src, ctx)
return expect(html).toMatch(/^\s+$/)
})
})
})