1
0
mirror of synced 2025-12-22 11:26:57 -05:00
Files
docs/tests/unit/liquid.js
Sarah Schneider aa5a62d49d Remove versions feature flag code (#15793)
* remove FEATURE_NEW_VERSIONS from feature-flags.json

* remove process.env.FEATURE_NEW_VERSIONS from include files

* remove process.env.FEATURE_NEW_VERSIONS from lib files

* remove process.env.FEATURE_NEW_VERSIONS from middleware files

* remove process.env.FEATURE_NEW_VERSIONS from script files

* remove process.env.FEATURE_NEW_VERSIONS from test files

* update test fixtures to use new versions as canonical fixtures
2020-09-29 13:36:07 -04:00

50 lines
1.4 KiB
JavaScript

const { liquid } = require('../../lib/render-content')
const template = `
{% if page.version ver_gt "2.13" %}up to date{% endif %}
{% if page.version ver_lt "2.13" %}out of date{% endif %}
`
describe('liquid template parser', () => {
describe('custom operators', () => {
describe('ver_gt', () => {
test('works as expected', async () => {
const context = {
page: {
version: '2.14'
}
}
const output = await liquid.parseAndRender(template, context)
expect(output.trim()).toBe('up to date')
})
test('returns false when given value is not numeric, like `dotcom`', async () => {
const context = {
page: {
version: 'dotcom'
}
}
const output = await liquid.parseAndRender(template, context)
expect(output.trim()).toBe('')
})
test('returns false when given value is falsy', async () => {
const context = {}
const output = await liquid.parseAndRender(template, context)
expect(output.trim()).toBe('')
})
})
describe('ver_lt', () => {
test('works as expected', async () => {
const context = {
page: {
version: '2.12'
}
}
const output = await liquid.parseAndRender(template, context)
expect(output.trim()).toBe('out of date')
})
})
})
})