forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathliquid-helpers.js
More file actions
63 lines (55 loc) · 2.03 KB
/
Copy pathliquid-helpers.js
File metadata and controls
63 lines (55 loc) · 2.03 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { afterAll, jest, beforeAll, expect } from '@jest/globals'
import { liquid } from '../../lib/render-content/index.js'
import languages from '../../lib/languages.js'
import { DataDirectory } from '../helpers/data-directory.js'
describe('liquid helper tags', () => {
jest.setTimeout(60 * 1000)
const context = {}
let dd
const enDirBefore = languages.en.dir
beforeAll(() => {
context.currentLanguage = 'en'
dd = new DataDirectory({
data: {
reusables: {
example: 'a rose by any other name\nwould smell as sweet',
},
},
})
languages.en.dir = dd.root
})
afterAll(() => {
dd.destroy()
languages.en.dir = enDirBefore
})
describe('indented_data_reference tag', () => {
test('without any number of spaces specified', async () => {
const template = '{% indented_data_reference reusables.example %}'
const expected = ` a rose by any other name
would smell as sweet`
const output = await liquid.parseAndRender(template, context)
expect(output).toBe(expected)
})
test('with 0 spaces specified', async () => {
const template = '{% indented_data_reference reusables.example spaces=0 %}'
const expected = `a rose by any other name
would smell as sweet`
const output = await liquid.parseAndRender(template, context)
expect(output).toBe(expected)
})
test('with 0 spaces specified and whitespace around equals sign', async () => {
const template = '{% indented_data_reference reusables.example spaces = 0 %}'
const expected = `a rose by any other name
would smell as sweet`
const output = await liquid.parseAndRender(template, context)
expect(output).toBe(expected)
})
test('with 5 spaces specified', async () => {
const template = '{% indented_data_reference reusables.example spaces=5 %}'
const expected = ` a rose by any other name
would smell as sweet`
const output = await liquid.parseAndRender(template, context)
expect(output).toBe(expected)
})
})
})