mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
fix: throw ParseError instead of RenderError for invalid assign expression, closes #519
This commit is contained in:
@@ -256,4 +256,8 @@ describe('Issues', function () {
|
||||
const html = engine.parseAndRenderSync(`{% for i in (1..10000) %}{{ i }}{% endfor %}`)
|
||||
expect(html).to.have.lengthOf(38894)
|
||||
})
|
||||
it('#519 should throw parse error for invalid assign expression', () => {
|
||||
const engine = new Liquid()
|
||||
expect(() => engine.parse('{% assign headshot = https://testurl.com/not_enclosed_in_quotes.jpg %}')).to.throw(/unexpected token at ":/)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Liquid } from '../../../../src/liquid'
|
||||
import { ParseError, Liquid } from '../../../../src/liquid'
|
||||
import { expect, use } from 'chai'
|
||||
import * as chaiAsPromised from 'chai-as-promised'
|
||||
|
||||
@@ -16,9 +16,10 @@ describe('tags/assign', function () {
|
||||
const html = await liquid.parseAndRender(src)
|
||||
return expect(html).to.equal('bar')
|
||||
})
|
||||
it('should throw when variable value illegal', async function () {
|
||||
it('should throw when variable value illegal', function () {
|
||||
const src = '{% assign foo = “bar” %}'
|
||||
return expect(liquid.parseAndRender(src)).to.be.rejectedWith(/unexpected token at "“bar”"/)
|
||||
expect(() => liquid.parse(src)).to.throw(/unexpected token at "“bar”"/)
|
||||
expect(() => liquid.parse(src)).to.throw(ParseError)
|
||||
})
|
||||
it('should support assign to a number', async function () {
|
||||
const src = '{% assign foo=10086 %}{{foo}}'
|
||||
|
||||
Reference in New Issue
Block a user