list_view_test.js 698 B

12345678910111213141516171819202122
  1. describe('ListView', function() {
  2. var collection;
  3. beforeEach(function() {
  4. collection = new Backbone.Collection();
  5. });
  6. it('should add children to the list element as they are added to the collection', function() {
  7. var view = new Whisper.ListView({collection: collection});
  8. collection.add('hello');
  9. assert.equal(view.$el.children().length, 1);
  10. collection.add('world');
  11. assert.equal(view.$el.children().length, 2);
  12. });
  13. it('should add all the children to the list element on reset', function() {
  14. var view = new Whisper.ListView({collection: collection});
  15. collection.reset(['goodbye', 'world']);
  16. assert.equal(view.$el.children().length, 2);
  17. });
  18. });