signal-desktop/test/views/list_view_test.js

27 lines
781 B
JavaScript
Raw Normal View History

2020-10-30 20:34:04 +00:00
// Copyright 2014-2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2018-11-02 18:02:53 +00:00
/* global Backbone, Whisper */
2018-11-02 18:02:53 +00:00
describe('ListView', () => {
let collection;
beforeEach(() => {
collection = new Backbone.Collection();
});
2018-11-02 18:02:53 +00:00
it('should add children to the list element as they are added to the collection', () => {
const view = new Whisper.ListView({ collection });
collection.add('hello');
assert.equal(view.$el.children().length, 1);
collection.add('world');
assert.equal(view.$el.children().length, 2);
});
2018-11-02 18:02:53 +00:00
it('should add all the children to the list element on reset', () => {
const view = new Whisper.ListView({ collection });
collection.reset(['goodbye', 'world']);
assert.equal(view.$el.children().length, 2);
});
});