|
@@ -98,7 +98,7 @@
|
|
|
it("happens when the client is idle for long enough", function () {
|
|
|
var i = 0;
|
|
|
// Usually initialized by registerIntervalHandler
|
|
|
- converse.idle_seconds = 0;
|
|
|
+ converse.idle_seconds = 0;
|
|
|
converse.auto_changed_status = false;
|
|
|
|
|
|
// The relevant config options
|
|
@@ -265,15 +265,15 @@
|
|
|
test_utils.createContacts('current');
|
|
|
}, converse));
|
|
|
|
|
|
- it("has a method 'get' which returns a wrapped chat box", $.proxy(function () {
|
|
|
+ it("has a method 'get' which returns a wrapped chat box", function () {
|
|
|
// Test on chat that doesn't exist.
|
|
|
expect(converse_api.chats.get('non-existing@jabber.org')).toBeFalsy();
|
|
|
+ var jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
|
|
|
|
|
// Test on chat that's not open
|
|
|
- var jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
|
|
var box = converse_api.chats.get(jid);
|
|
|
expect(box instanceof Object).toBeTruthy();
|
|
|
- var chatboxview = this.chatboxviews.get(jid);
|
|
|
+ var chatboxview = converse.chatboxviews.get(jid);
|
|
|
expect(chatboxview.$el.is(':visible')).toBeFalsy();
|
|
|
|
|
|
// Test for single JID
|
|
@@ -281,9 +281,8 @@
|
|
|
box = converse_api.chats.get(jid);
|
|
|
expect(box instanceof Object).toBeTruthy();
|
|
|
expect(box.get('box_id')).toBe(b64_sha1(jid));
|
|
|
- chatboxview = this.chatboxviews.get(jid);
|
|
|
+ chatboxview = converse.chatboxviews.get(jid);
|
|
|
expect(chatboxview.$el.is(':visible')).toBeTruthy();
|
|
|
-
|
|
|
// Test for multiple JIDs
|
|
|
var jid2 = mock.cur_names[1].replace(/ /g,'.').toLowerCase() + '@localhost';
|
|
|
test_utils.openChatBoxFor(jid2);
|
|
@@ -291,30 +290,32 @@
|
|
|
expect(Array.isArray(list)).toBeTruthy();
|
|
|
expect(list[0].get('box_id')).toBe(b64_sha1(jid));
|
|
|
expect(list[1].get('box_id')).toBe(b64_sha1(jid2));
|
|
|
- }, converse));
|
|
|
-
|
|
|
- it("has a method 'open' which opens and returns a wrapped chat box", $.proxy(function () {
|
|
|
- // Test on chat that doesn't exist.
|
|
|
- expect(converse_api.chats.get('non-existing@jabber.org')).toBeFalsy();
|
|
|
+ });
|
|
|
|
|
|
+ it("has a method 'open' which opens and returns a wrapped chat box", function () {
|
|
|
var jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
|
|
- var box = converse_api.chats.open(jid);
|
|
|
- expect(box instanceof Object).toBeTruthy();
|
|
|
- expect(box.get('box_id')).toBe(b64_sha1(jid));
|
|
|
- expect(
|
|
|
- Object.keys(box),
|
|
|
- ['close', 'endOTR', 'focus', 'get', 'initiateOTR', 'is_chatroom', 'maximize', 'minimize', 'open', 'set']
|
|
|
- );
|
|
|
- var chatboxview = this.chatboxviews.get(jid);
|
|
|
- expect(chatboxview.$el.is(':visible')).toBeTruthy();
|
|
|
-
|
|
|
- // Test for multiple JIDs
|
|
|
- var jid2 = mock.cur_names[1].replace(/ /g,'.').toLowerCase() + '@localhost';
|
|
|
- var list = converse_api.chats.open([jid, jid2]);
|
|
|
- expect(Array.isArray(list)).toBeTruthy();
|
|
|
- expect(list[0].get('box_id')).toBe(b64_sha1(jid));
|
|
|
- expect(list[1].get('box_id')).toBe(b64_sha1(jid2));
|
|
|
- }, converse));
|
|
|
+ var chatboxview;
|
|
|
+ waits('300'); // ChatBox.show() is debounced for 250ms
|
|
|
+ runs(function () {
|
|
|
+ // Test on chat that doesn't exist.
|
|
|
+ expect(converse_api.chats.get('non-existing@jabber.org')).toBeFalsy();
|
|
|
+ var box = converse_api.chats.open(jid);
|
|
|
+ expect(box instanceof Object).toBeTruthy();
|
|
|
+ expect(box.get('box_id')).toBe(b64_sha1(jid));
|
|
|
+ expect(
|
|
|
+ Object.keys(box),
|
|
|
+ ['close', 'endOTR', 'focus', 'get', 'initiateOTR', 'is_chatroom', 'maximize', 'minimize', 'open', 'set']
|
|
|
+ );
|
|
|
+ chatboxview = converse.chatboxviews.get(jid);
|
|
|
+ expect(chatboxview.$el.is(':visible')).toBeTruthy();
|
|
|
+ // Test for multiple JIDs
|
|
|
+ var jid2 = mock.cur_names[1].replace(/ /g,'.').toLowerCase() + '@localhost';
|
|
|
+ var list = converse_api.chats.open([jid, jid2]);
|
|
|
+ expect(Array.isArray(list)).toBeTruthy();
|
|
|
+ expect(list[0].get('box_id')).toBe(b64_sha1(jid));
|
|
|
+ expect(list[1].get('box_id')).toBe(b64_sha1(jid2));
|
|
|
+ });
|
|
|
+ });
|
|
|
}, converse));
|
|
|
|
|
|
describe("The \"rooms\" API", function () {
|
|
@@ -326,77 +327,91 @@
|
|
|
});
|
|
|
|
|
|
it("has a method 'get' which returns a wrapped chat room (if it exists)", function () {
|
|
|
- test_utils.openChatRoom('lounge', 'localhost', 'dummy');
|
|
|
- var jid = 'lounge@localhost';
|
|
|
- var room = converse_api.rooms.get(jid);
|
|
|
- expect(room instanceof Object).toBeTruthy();
|
|
|
- expect(room.is_chatroom).toBeTruthy();
|
|
|
- var chatroomview = converse.chatboxviews.get(jid);
|
|
|
- expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
|
|
- chatroomview.close();
|
|
|
-
|
|
|
- // Test with mixed case
|
|
|
- test_utils.openChatRoom('Leisure', 'localhost', 'dummy');
|
|
|
- jid = 'Leisure@localhost';
|
|
|
- room = converse_api.rooms.get(jid);
|
|
|
- expect(room instanceof Object).toBeTruthy();
|
|
|
- chatroomview = converse.chatboxviews.get(jid.toLowerCase());
|
|
|
- expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
|
|
-
|
|
|
- jid = 'leisure@localhost';
|
|
|
- room = converse_api.rooms.get(jid);
|
|
|
- expect(room instanceof Object).toBeTruthy();
|
|
|
- chatroomview = converse.chatboxviews.get(jid.toLowerCase());
|
|
|
- expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
|
|
-
|
|
|
- jid = 'leiSure@localhost';
|
|
|
- room = converse_api.rooms.get(jid);
|
|
|
- expect(room instanceof Object).toBeTruthy();
|
|
|
- chatroomview = converse.chatboxviews.get(jid.toLowerCase());
|
|
|
- expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
|
|
- chatroomview.close();
|
|
|
-
|
|
|
- // Non-existing room
|
|
|
- jid = 'lounge2@localhost';
|
|
|
- room = converse_api.rooms.get(jid);
|
|
|
- expect(typeof room === 'undefined').toBeTruthy();
|
|
|
+ waits('300'); // ChatBox.show() is debounced for 250ms
|
|
|
+ runs(function () {
|
|
|
+ test_utils.openChatRoom('lounge', 'localhost', 'dummy');
|
|
|
+ var jid = 'lounge@localhost';
|
|
|
+ var room = converse_api.rooms.get(jid);
|
|
|
+ expect(room instanceof Object).toBeTruthy();
|
|
|
+ expect(room.is_chatroom).toBeTruthy();
|
|
|
+ var chatroomview = converse.chatboxviews.get(jid);
|
|
|
+ expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
|
|
+ chatroomview.close();
|
|
|
+ });
|
|
|
+ waits('300'); // ChatBox.show() is debounced for 250ms
|
|
|
+ runs(function () {
|
|
|
+ // Test with mixed case
|
|
|
+ test_utils.openChatRoom('Leisure', 'localhost', 'dummy');
|
|
|
+ var jid = 'Leisure@localhost';
|
|
|
+ var room = converse_api.rooms.get(jid);
|
|
|
+ expect(room instanceof Object).toBeTruthy();
|
|
|
+ var chatroomview = converse.chatboxviews.get(jid.toLowerCase());
|
|
|
+ expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
|
|
+ });
|
|
|
+ waits('300'); // ChatBox.show() is debounced for 250ms
|
|
|
+ runs(function () {
|
|
|
+ var jid = 'leisure@localhost';
|
|
|
+ var room = converse_api.rooms.get(jid);
|
|
|
+ expect(room instanceof Object).toBeTruthy();
|
|
|
+ var chatroomview = converse.chatboxviews.get(jid.toLowerCase());
|
|
|
+ expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
|
|
+
|
|
|
+ jid = 'leiSure@localhost';
|
|
|
+ room = converse_api.rooms.get(jid);
|
|
|
+ expect(room instanceof Object).toBeTruthy();
|
|
|
+ chatroomview = converse.chatboxviews.get(jid.toLowerCase());
|
|
|
+ expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
|
|
+ chatroomview.close();
|
|
|
+
|
|
|
+ // Non-existing room
|
|
|
+ jid = 'lounge2@localhost';
|
|
|
+ room = converse_api.rooms.get(jid);
|
|
|
+ expect(typeof room === 'undefined').toBeTruthy();
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
it("has a method 'open' which opens and returns a wrapped chat box", function () {
|
|
|
- // Test on chat room that doesn't exist.
|
|
|
+ var chatroomview;
|
|
|
var jid = 'lounge@localhost';
|
|
|
var room = converse_api.rooms.open(jid);
|
|
|
- expect(room instanceof Object).toBeTruthy();
|
|
|
- expect(room.is_chatroom).toBeTruthy();
|
|
|
- var chatroomview = converse.chatboxviews.get(jid);
|
|
|
- expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
|
|
-
|
|
|
- // Test again, now that the room exists.
|
|
|
- room = converse_api.rooms.open(jid);
|
|
|
- expect(room instanceof Object).toBeTruthy();
|
|
|
- expect(room.is_chatroom).toBeTruthy();
|
|
|
- chatroomview = converse.chatboxviews.get(jid);
|
|
|
- expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
|
|
-
|
|
|
- // Test with mixed case in JID
|
|
|
- jid = 'Leisure@localhost';
|
|
|
- room = converse_api.rooms.open(jid);
|
|
|
- expect(room instanceof Object).toBeTruthy();
|
|
|
- chatroomview = converse.chatboxviews.get(jid.toLowerCase());
|
|
|
- expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
|
|
-
|
|
|
- jid = 'leisure@localhost';
|
|
|
- room = converse_api.rooms.open(jid);
|
|
|
- expect(room instanceof Object).toBeTruthy();
|
|
|
- chatroomview = converse.chatboxviews.get(jid.toLowerCase());
|
|
|
- expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
|
|
-
|
|
|
- jid = 'leiSure@localhost';
|
|
|
- room = converse_api.rooms.open(jid);
|
|
|
- expect(room instanceof Object).toBeTruthy();
|
|
|
- chatroomview = converse.chatboxviews.get(jid.toLowerCase());
|
|
|
- expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
|
|
- chatroomview.close();
|
|
|
+ runs(function () {
|
|
|
+ // Test on chat room that doesn't exist.
|
|
|
+ expect(room instanceof Object).toBeTruthy();
|
|
|
+ expect(room.is_chatroom).toBeTruthy();
|
|
|
+ chatroomview = converse.chatboxviews.get(jid);
|
|
|
+ expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
|
|
+ });
|
|
|
+ waits('300'); // ChatBox.show() is debounced for 250ms
|
|
|
+ runs(function () {
|
|
|
+ // Test again, now that the room exists.
|
|
|
+ room = converse_api.rooms.open(jid);
|
|
|
+ expect(room instanceof Object).toBeTruthy();
|
|
|
+ expect(room.is_chatroom).toBeTruthy();
|
|
|
+ chatroomview = converse.chatboxviews.get(jid);
|
|
|
+ expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
|
|
+ });
|
|
|
+ waits('300'); // ChatBox.show() is debounced for 250ms
|
|
|
+ runs(function () {
|
|
|
+ // Test with mixed case in JID
|
|
|
+ jid = 'Leisure@localhost';
|
|
|
+ room = converse_api.rooms.open(jid);
|
|
|
+ expect(room instanceof Object).toBeTruthy();
|
|
|
+ chatroomview = converse.chatboxviews.get(jid.toLowerCase());
|
|
|
+ expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
|
|
+
|
|
|
+ jid = 'leisure@localhost';
|
|
|
+ room = converse_api.rooms.open(jid);
|
|
|
+ expect(room instanceof Object).toBeTruthy();
|
|
|
+ chatroomview = converse.chatboxviews.get(jid.toLowerCase());
|
|
|
+ expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
|
|
+
|
|
|
+ jid = 'leiSure@localhost';
|
|
|
+ room = converse_api.rooms.open(jid);
|
|
|
+ expect(room instanceof Object).toBeTruthy();
|
|
|
+ chatroomview = converse.chatboxviews.get(jid.toLowerCase());
|
|
|
+ expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
|
|
+ chatroomview.close();
|
|
|
+ });
|
|
|
});
|
|
|
});
|
|
|
|