spec/components/collection_view_spec.coffee in luca-0.9.6 vs spec/components/collection_view_spec.coffee in luca-0.9.7
- old
+ new
@@ -1,20 +1,42 @@
describe 'The Collection View', ->
beforeEach ->
@collection = new Luca.Collection([
- id: 1, attr: "value_one"
+ id: 1, attr: "value_one", filter: "value"
,
- id: 2, attr: "value_two"
+ id: 2, attr: "value_two", filter: "value"
],
model: Luca.Model)
@view = new Luca.components.CollectionView
itemTagName: "li"
itemClassName: "custom-class"
itemProperty: 'attr'
collection: @collection
+ filterable:
+ query:
+ filter: "value"
+ options:
+ sortBy: "filter"
@view.render()
+
+ it "should provide access to the query", ->
+ expect( @view.getQuery() ).toBeDefined()
+
+ it "should provide access to the query options", ->
+ expect( @view.getQueryOptions() ).toBeDefined()
+
+ it "should combine filter and pagination in the options hash", ->
+ @view.setPage(5)
+ @view.applyFilter({filter:"value"},{sortBy:'filter'})
+
+ options = @view.getQueryOptions()
+ query = @view.getQuery()
+
+ expect( options.page ).toEqual 5
+ expect( options.sortBy ).toEqual 'filter'
+ expect( query.filter ).toEqual 'value'
it "should render the attributes in the specified list elements", ->
expect( @view.$html() ).toContain('value_one')
it "should render each of the attributes", ->