Commit 79a51212 authored by JC Brand's avatar JC Brand

Also test for users leaving a room. updates #307

parent 6c31f764
......@@ -27,19 +27,18 @@
var view = this.chatboxviews.get('lounge@localhost'),
$participants = view.$('.participant-list');
spyOn(view, 'onChatRoomPresence').andCallThrough();
var room = {}, i, role;
var presence, room = {}, i, role;
for (i=0; i<mock.chatroom_names.length; i++) {
name = mock.chatroom_names[i];
console.log(name);
role = mock.chatroom_roles[name].role;
// See example 21 http://xmpp.org/extensions/xep-0045.html#enter-pres
var presence = $pres({
presence = $pres({
to:'dummy@localhost/pda',
from:'lounge@localhost/'+name
}).c('x').attrs({xmlns:'http://jabber.org/protocol/muc#user'})
.c('item').attrs({
affiliation: mock.chatroom_roles[name].affiliation,
jid: 'dummy@localhost/pda',
jid: name.replace(/ /g,'.').toLowerCase() + '@localhost',
role: role
}).up()
.c('status').attrs({code:'110'}).nodeTree;
......@@ -50,6 +49,28 @@
expect($($participants.find('li')[i]).text()).toBe(mock.chatroom_names[i]);
expect($($participants.find('li')[i]).hasClass('moderator')).toBe(role === "moderator");
}
// Test users leaving the room
// http://xmpp.org/extensions/xep-0045.html#exit
for (i=mock.chatroom_names.length-1; i>-1; i--) {
name = mock.chatroom_names[i];
console.log(name);
role = mock.chatroom_roles[name].role;
// See example 21 http://xmpp.org/extensions/xep-0045.html#enter-pres
presence = $pres({
to:'dummy@localhost/pda',
from:'lounge@localhost/'+name,
type: 'unavailable'
}).c('x').attrs({xmlns:'http://jabber.org/protocol/muc#user'})
.c('item').attrs({
affiliation: mock.chatroom_roles[name].affiliation,
jid: name.replace(/ /g,'.').toLowerCase() + '@localhost',
role: 'none'
}).nodeTree;
this.connection._dataRecv(test_utils.createRequest(presence));
expect(view.onChatRoomPresence).toHaveBeenCalled();
expect($participants.find('li').length).toBe(i);
}
}, converse));
it("indicates moderators by means of a special css class and tooltip", $.proxy(function () {
......@@ -62,7 +83,7 @@
}).c('x').attrs({xmlns:'http://jabber.org/protocol/muc#user'})
.c('item').attrs({
affiliation: 'admin',
jid: 'dummy@localhost/pda',
jid: name.replace(/ /g,'.').toLowerCase() + '@localhost',
role: 'moderator',
}).up()
.c('status').attrs({code:'110'}).nodeTree;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment