forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathghae-versioning.js
More file actions
62 lines (57 loc) · 1.45 KB
/
Copy pathghae-versioning.js
File metadata and controls
62 lines (57 loc) · 1.45 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
import { allVersions } from '../../lib/all-versions.js'
import { liquid } from '../../lib/render-content/index.js'
import shortVersionsMiddleware from '../../middleware/contextualizers/short-versions.js'
describe('ifversion conditionals', () => {
const req = {}
beforeAll(async () => {
req.context = {
allVersions,
currentVersion: 'github-ae@latest',
}
await shortVersionsMiddleware(req, null, () => {})
})
test('greater than', async () => {
const template = `
{% ifversion ghae > 3.2 %}
FOO
{% else %}
BAR
{% endif %}
`
const output = await liquid.parseAndRender(template, req.context)
expect(output.trim()).toBe('FOO')
})
test('less than', async () => {
const template = `
{% ifversion ghae < 3.2 %}
FOO
{% else %}
BAR
{% endif %}
`
const output = await liquid.parseAndRender(template, req.context)
expect(output.trim()).toBe('BAR')
})
test('Equal', async () => {
const template = `
{% ifversion ghae %}
FOO
{% else %}
BAR
{% endif %}
`
const output = await liquid.parseAndRender(template, req.context)
expect(output.trim()).toBe('FOO')
})
test('Not', async () => {
const template = `
{% ifversion not ghae %}
FOO
{% else %}
BAR
{% endif %}
`
const output = await liquid.parseAndRender(template, req.context)
expect(output.trim()).toBe('BAR')
})
})