mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-17 21:40:39 -07:00
feature: get nyc, babel and coveralls working
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import chai from 'chai'
|
||||
import sinonChai from 'sinon-chai'
|
||||
import Filter from '../../src/filter.js'
|
||||
import Tag from '../../src/tag.js'
|
||||
import Template from '../../src/parser.js'
|
||||
|
||||
const expect = chai.expect
|
||||
const filter = Filter()
|
||||
const tag = Tag()
|
||||
chai.use(sinonChai)
|
||||
|
||||
describe('template', function () {
|
||||
let template
|
||||
const add = (l, r) => l + r
|
||||
|
||||
beforeEach(function () {
|
||||
filter.clear()
|
||||
filter.register('add', add)
|
||||
|
||||
tag.clear()
|
||||
template = Template(tag, filter)
|
||||
})
|
||||
|
||||
it('should throw when value string illegal', function () {
|
||||
expect(function () {
|
||||
template.parseValue('/')
|
||||
}).to.throw(/illegal value string/)
|
||||
})
|
||||
|
||||
it('should parse value string', function () {
|
||||
const tpl = template.parseValue('foo')
|
||||
expect(tpl.type).to.equal('value')
|
||||
expect(tpl.initial).to.equal('foo')
|
||||
expect(tpl.filters).to.deep.equal([])
|
||||
})
|
||||
|
||||
it('should parse value string with a simple filter', function () {
|
||||
const tpl = template.parseValue('foo | add: 3, "foo"')
|
||||
expect(tpl.initial).to.equal('foo')
|
||||
expect(tpl.filters.length).to.equal(1)
|
||||
expect(tpl.filters[0].filter).to.equal(add)
|
||||
})
|
||||
|
||||
it('should parse value string with filters', function () {
|
||||
const tpl = template.parseValue('foo | add: "|" | add')
|
||||
expect(tpl.initial).to.equal('foo')
|
||||
expect(tpl.filters.length).to.equal(2)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user