feature: get nyc, babel and coveralls working

This commit is contained in:
harttle
2018-08-26 21:54:35 +08:00
parent d828c4021e
commit 31c39561c9
50 changed files with 361 additions and 482 deletions
+49
View File
@@ -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)
})
})