feature: separate options for value/tag trimming, working on #17

This commit is contained in:
harttle
2017-10-30 01:46:31 +08:00
parent 502426f621
commit e8fa8d32f5
15 changed files with 236 additions and 147 deletions
+7 -7
View File
@@ -44,23 +44,23 @@ describe('render', function () {
var time = sinon.spy()
filter.register('date', date)
filter.register('time', time)
var tpl = Template.parseOutput('foo.bar[0] | date: "b" | time:2')
render.evalOutput(tpl, scope)
var tpl = Template.parseValue('foo.bar[0] | date: "b" | time:2')
render.evalValue(tpl, scope)
expect(date).to.have.been.calledWith('a', 'b')
expect(time).to.have.been.calledWith('y', 2)
})
describe('.evalOutput()', function () {
describe('.evalValue()', function () {
it('should throw when scope undefined', function () {
expect(function () {
render.evalOutput()
render.evalValue()
}).to.throw(/scope undefined/)
})
it('should eval output', function () {
it('should eval value', function () {
filter.register('date', (l, r) => l + r)
filter.register('time', (l, r) => l + 3 * r)
var tpl = Template.parseOutput('foo.bar[0] | date: "b" | time:2')
expect(render.evalOutput(tpl, scope)).to.equal('ab6')
var tpl = Template.parseValue('foo.bar[0] | date: "b" | time:2')
expect(render.evalValue(tpl, scope)).to.equal('ab6')
})
})
})