Files
liquidjs/test/integration/liquid/strict.ts
T
Jun Yang 64e0c876e9 refactor: use camelCase for JavaScript APIs
BREAKING CHANGE: Options and method names in JavaScript API are now renamed to cammelCase, for a complete list see #109
2019-03-10 19:21:09 +08:00

34 lines
1.0 KiB
TypeScript

import Liquid from '../../../src/liquid'
import { expect } from 'chai'
describe('LiquidOptions#strict*', function () {
let engine: Liquid
const ctx = {}
beforeEach(function () {
engine = new Liquid({
root: '/root/',
extname: '.html'
})
})
it('should not throw when strictVariables false (default)', async function () {
const html = await engine.parseAndRender('before{{notdefined}}after', ctx)
return expect(html).to.equal('beforeafter')
})
it('should throw when strictVariables true', function () {
const tpl = engine.parse('before{{notdefined}}after')
const opts = {
strictVariables: true
}
return expect(engine.render(tpl, ctx, opts)).to
.be.rejectedWith(/undefined variable: notdefined/)
})
it('should pass strictVariables to render by parseAndRender', function () {
const html = 'before{{notdefined}}after'
const opts = {
strictVariables: true
}
return expect(engine.parseAndRender(html, ctx, opts)).to
.be.rejectedWith(/undefined variable: notdefined/)
})
})