mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 20:30:39 -07:00
@@ -1,6 +1,8 @@
|
||||
import { test } from '../../../stub/render'
|
||||
import { Liquid } from '../../../../src/liquid'
|
||||
import { expect } from 'chai'
|
||||
import { expect, use } from 'chai'
|
||||
import * as chaiAsPromised from 'chai-as-promised'
|
||||
use(chaiAsPromised)
|
||||
|
||||
describe('filters/array', function () {
|
||||
let liquid: Liquid
|
||||
@@ -25,6 +27,11 @@ describe('filters/array', function () {
|
||||
'{{ beatles | join }}'
|
||||
return test(src, 'John Paul George Ringo')
|
||||
})
|
||||
it('should throw when comma missing', async () => {
|
||||
const src = '{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}' +
|
||||
'{{ beatles | join " and " }}'
|
||||
return expect(liquid.parseAndRender(src)).to.be.rejectedWith('unexpected token at "\\" and \\"", line:1, col:65')
|
||||
})
|
||||
})
|
||||
it('should support split/last', function () {
|
||||
const src = '{% assign my_array = "zebra, octopus, giraffe, tiger" | split: ", " %}' +
|
||||
|
||||
@@ -207,6 +207,11 @@ describe('Tokenize', function () {
|
||||
expect(token).to.have.property('name', 'plus')
|
||||
expect(token).to.have.property('args').to.deep.equal([])
|
||||
})
|
||||
it('should read null if name not found', function () {
|
||||
const tokenizer = new Tokenizer('|')
|
||||
const token = tokenizer.readFilter()
|
||||
expect(token).to.be.null
|
||||
})
|
||||
it('should read a filter with k/v argument', function () {
|
||||
const tokenizer = new Tokenizer(' | plus: a:1')
|
||||
const token = tokenizer.readFilter()
|
||||
|
||||
Reference in New Issue
Block a user