From 6c31f76406c1ff5fa0bed13cdd337b9864828aa4 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Sun, 1 Mar 2015 11:58:07 +0100 Subject: [PATCH] Refactor other tests. All tests pass now again. updates #307 --- converse.js | 9 ++++--- spec/chatroom.js | 64 +++++++++++++++++++++++++++++++++--------------- tests/mock.js | 9 +++++++ 3 files changed, 58 insertions(+), 24 deletions(-) diff --git a/converse.js b/converse.js index 51cf1455f..f0d610f21 100644 --- a/converse.js +++ b/converse.js @@ -2523,9 +2523,10 @@ }, leave: function(exit_msg) { + var presenceid = converse.connection.getUniqueId(); var presence = $pres({ type: "unavailable", - id: converse.connection.getUniqueId(), + id: presenceid, from: converse.connection.jid, to: this.getRoomJID() }); @@ -2772,10 +2773,10 @@ return this.scrollDown(); }, - showErrorMessage: function ($error, room) { + showErrorMessage: function ($error) { // We didn't enter the room, so we must remove it from the MUC // add-on - delete converse.connection.muc[room.name]; + delete converse.connection.muc[this.model.get('jid')]; // XXX: Still needed? if ($error.attr('type') == 'auth') { if ($error.find('not-authorized').length) { this.renderPasswordForm(); @@ -2810,7 +2811,7 @@ var nick = this.model.get('nick'); if ($presence.attr('type') === 'error') { this.model.set('connected', false); - this.showErrorMessage($presence.find('error'), room); + this.showErrorMessage($presence.find('error')); } else { is_self = ($presence.find("status[code='110']").length) || ($presence.attr('from') == this.model.get('id')+'/'+Strophe.escapeNode(nick)); diff --git a/spec/chatroom.js b/spec/chatroom.js index a4a4a8a66..b127eac79 100644 --- a/spec/chatroom.js +++ b/spec/chatroom.js @@ -23,30 +23,54 @@ it("shows users currently present in the room", $.proxy(function () { test_utils.openChatRoom('lounge', 'localhost', 'dummy'); - var chatroomview = this.chatboxviews.get('lounge@localhost'), - $participant_list; - var roster = {}, room = {}, i; - for (i=0; i