roomslist: expand tests

This commit is contained in:
JC Brand 2017-05-16 13:31:31 +02:00
parent 095606a824
commit 6b2ca629cc
2 changed files with 25 additions and 2 deletions

View File

@ -11,16 +11,39 @@
// have to mock stanza traffic.
},
function (_converse) {
test_utils.openControlBox().openRoomsPanel(_converse);
var controlbox = _converse.chatboxviews.get('controlbox');
var list = controlbox.el.querySelector('div.rooms-list-container');
expect(_.includes(list.classList, 'hidden')).toBeTruthy();
test_utils.openChatRoom(
_converse, 'theplay', 'conference.shakespeare.lit', 'JC');
_converse, 'room', 'conference.shakespeare.lit', 'JC');
expect(_.isUndefined(_converse.rooms_list_view)).toBeFalsy();
var room_els = _converse.rooms_list_view.el.querySelectorAll(".open-room");
expect(room_els.length).toBe(1);
expect(room_els[0].innerText).toBe('room');
test_utils.openChatRoom(_converse, 'lounge', 'localhost', 'dummy');
room_els = _converse.rooms_list_view.el.querySelectorAll(".open-room");
expect(room_els.length).toBe(2);
var view = _converse.chatboxviews.get('room@conference.shakespeare.lit');
view.close();
room_els = _converse.rooms_list_view.el.querySelectorAll(".open-room");
expect(room_els.length).toBe(1);
expect(room_els[0].innerText).toBe('lounge');
list = controlbox.el.querySelector('div.rooms-list-container');
expect(_.includes(list.classList, 'hidden')).toBeFalsy();
view = _converse.chatboxviews.get('lounge@localhost');
view.close();
room_els = _converse.rooms_list_view.el.querySelectorAll(".open-room");
expect(room_els.length).toBe(0);
list = controlbox.el.querySelector('div.rooms-list-container');
expect(_.includes(list.classList, 'hidden')).toBeTruthy();
}
));
});

View File

@ -40,7 +40,7 @@
_converse.RoomsListView = Backbone.View.extend({
tagName: 'div',
className: 'open-rooms-list, rooms-list-container',
className: 'open-rooms-list rooms-list-container',
events: {
'click .close-room': 'closeRoom',
'click .open-rooms-toggle': 'toggleRoomsList'