Skip to content

Commit

Permalink
add test for directive literal number arg + limitBy with v-for
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Oct 29, 2015
1 parent e8efd64 commit 14a1fb4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions test/unit/specs/directives/public/for/for_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ if (_.inBrowser) {
it('array filters', function (done) {
var vm = new Vue({
el: el,
template: '<div v-for="item in list | filterBy filterKey | orderBy sortKey -1">{{item.id}}</div>',
template: '<div v-for="item in list | filterBy filterKey | orderBy sortKey -1 | limitBy 2">{{item.id}}</div>',
data: {
filterKey: 'hi!',
sortKey: 'id',
Expand Down Expand Up @@ -426,7 +426,9 @@ if (_.inBrowser) {
})
.map(function (item) {
return '<div>' + item.id + '</div>'
}).join('')
})
.slice(0, 2)
.join('')
expect(el.innerHTML).toBe(markup)
}
})
Expand Down
6 changes: 4 additions & 2 deletions test/unit/specs/parsers/directive_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ describe('New Directive Parser', function () {
})

it('with filters', function () {
var res = parse('exp | abc de \'ok\' \'\' | bcd')
var res = parse('exp | abc de \'ok\' \'\' 123 | bcd')
expect(res.expression).toBe('exp')
expect(res.filters.length).toBe(2)
expect(res.filters[0].name).toBe('abc')
expect(res.filters[0].args.length).toBe(3)
expect(res.filters[0].args.length).toBe(4)
expect(res.filters[0].args[0].value).toBe('de')
expect(res.filters[0].args[0].dynamic).toBe(true)
expect(res.filters[0].args[1].value).toBe('ok')
expect(res.filters[0].args[1].dynamic).toBe(false)
expect(res.filters[0].args[2].value).toBe('')
expect(res.filters[0].args[2].dynamic).toBe(false)
expect(res.filters[0].args[3].value).toBe(123)
expect(res.filters[0].args[3].dynamic).toBe(false)
expect(res.filters[1].name).toBe('bcd')
expect(res.filters[1].args).toBeUndefined()
})
Expand Down

0 comments on commit 14a1fb4

Please sign in to comment.