1
0
mirror of synced 2025-12-22 19:34:15 -05:00
Files
docs/tests/unit/ghae-versioning.js
2023-06-26 18:48:29 +00:00

63 lines
1.4 KiB
JavaScript

import { allVersions } from '../../lib/all-versions.js'
import { liquid } from '#src/content-render/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')
})
})