backbone-generator/templates/collection_view_spec.coffee...

27 lines
821 B
Plaintext
Raw Normal View History

2011-05-09 02:44:21 +00:00
describe '<%= plural_object_name %>View', ->
view = collection = null
beforeEach ->
collection = new <%= plural_object_name %>()
2011-05-09 11:35:37 +00:00
view = new <%= plural_object_name %>View({collection: collection})
view.render()
2011-05-09 02:44:21 +00:00
it 'should render', ->
expect($(view.el)).toContain('.list')
2011-05-09 11:35:37 +00:00
expect($(view.el)).toContain('button.new')
2011-05-09 02:44:21 +00:00
it 'should add a new model when new is clicked', ->
view.$('button.new').trigger('click')
2011-05-09 11:35:37 +00:00
expect(view.$('.list')).toContain('.<%= css_class_name %>')
2011-05-09 02:44:21 +00:00
expect(collection.length).toEqual(1)
2011-05-13 14:22:13 +00:00
it 'should render the models when re-rendered', ->
expect(view.$('.list')).not.toContain('.<%= css_class_name %>')
model = new <%= object_name %>({id: 1})
collection.add(model)
view.render()
expect(view.$('.list')).toContain('.<%= css_class_name %>')