-
-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathliquid.test.js
More file actions
89 lines (68 loc) · 1.83 KB
/
liquid.test.js
File metadata and controls
89 lines (68 loc) · 1.83 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
require('../scripts/construct-leaflet-map');
const plugin = window.WPLeafletMapPlugin;
describe('liquid', () => {
const observer = jest.fn();
beforeEach(() => {
jest.clearAllMocks();
});
it('parses a boolean filter', () => {
const str = '{ test | isBoolean }';
plugin.liquid(str, observer);
expect(observer).toHaveBeenCalledWith(
str,
expect.objectContaining({
key: 'test',
isBoolean: true,
})
);
});
it('also parses when liquid tag is doubled', () => {
const str = '{{ test }}';
plugin.liquid(str, observer);
expect(observer).toHaveBeenCalledWith(
str,
expect.objectContaining({
key: 'test',
})
);
});
it('does not parse when tag is malformed', () => {
const str = '{ test ';
const output = plugin.liquid(str, observer);
expect(observer).not.toHaveBeenCalled();
expect(output).toEqual(str);
});
it('does not parse when bar is missing whitespace', () => {
const str = '{ test|isBoolean }';
const output = plugin.liquid(str, observer);
expect(observer).toHaveBeenCalledWith(
expect.any(String),
expect.not.objectContaining({
isBoolean: true,
})
);
});
it('accepts multiple filters', () => {
const str = '{ test | default: yolo | substr: 0,4 | lowercase }';
plugin.liquid(str, observer);
expect(observer).toHaveBeenCalledWith(
expect.any(String),
expect.objectContaining({
key: 'test',
default: 'yolo',
substr: '0,4',
lowercase: true,
})
);
});
it('does not have key as a filter', () => {
const str = '{ key | key: not key }';
plugin.liquid(str, observer);
expect(observer).toHaveBeenCalledWith(
expect.any(String),
expect.objectContaining({
key: 'key',
})
);
});
});