backbone-generator/templates/collection_view_spec.js.erb

23 lines
614 B
Plaintext
Raw Normal View History

describe('<%= plural_object_name %>View', function() {
var view, collection;
beforeEach(function() {
collection = new <%= plural_object_name %>();
});
it('should render', function() {
2011-05-03 19:43:19 +00:00
view = new <%= plural_object_name %>View({collection: collection});
view.render();
expect($(view.el)).toContain('.list');
2011-05-03 19:43:19 +00:00
expect($(view.el)).toContain('button.new');
});
it('should add a new model when new is clicked', function() {
2011-05-03 19:53:36 +00:00
view.$('button.new').trigger('click');
2011-05-03 19:43:19 +00:00
2011-05-03 19:53:36 +00:00
expect(view.$('.list')).toContain('.<%= underscore_name %>');
expect(collection.length).toEqual(1);
});
});