Used debounce ineffectually. Fixed now.
The ChatBox.show() method was being called for every invocation, 100ms after the fact, instead of it being called only once. Fixed that and also changed to call it at the start.
This commit is contained in:
parent
e94904e4a1
commit
da0c858fe0
159
spec/chatbox.js
159
spec/chatbox.js
@ -104,24 +104,23 @@
|
|||||||
var $el, jid, chatboxview, chatbox;
|
var $el, jid, chatboxview, chatbox;
|
||||||
// openControlBox was called earlier, so the controlbox is
|
// openControlBox was called earlier, so the controlbox is
|
||||||
// visible, but no other chat boxes have been created.
|
// visible, but no other chat boxes have been created.
|
||||||
expect(this.chatboxes.length).toEqual(1);
|
expect(converse.chatboxes.length).toEqual(1);
|
||||||
chatbox = test_utils.openChatBoxFor(contact_jid);
|
chatbox = test_utils.openChatBoxFor(contact_jid);
|
||||||
chatboxview = this.chatboxviews.get(contact_jid);
|
chatboxview = converse.chatboxviews.get(contact_jid);
|
||||||
spyOn(chatboxview, 'focus');
|
spyOn(chatboxview, 'focus');
|
||||||
|
|
||||||
// Test that they can be trimmed
|
// Test that they can be trimmed
|
||||||
runs(function () {
|
runs(function () {
|
||||||
converse.rosterview.update(); // XXX: Hack to make sure $roster element is attaced.
|
converse.rosterview.update(); // XXX: Hack to make sure $roster element is attaced.
|
||||||
}.bind(this));
|
});
|
||||||
waits(50);
|
waits(300); // ChatBox.show() is debounced for 250ms
|
||||||
runs(function () {
|
runs(function () {
|
||||||
$el = this.rosterview.$el.find('a.open-chat:contains("'+chatbox.get('fullname')+'")');
|
$el = converse.rosterview.$el.find('a.open-chat:contains("'+chatbox.get('fullname')+'")');
|
||||||
jid = $el.text().replace(/ /g,'.').toLowerCase() + '@localhost';
|
jid = $el.text().replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
$el.click();
|
$el.click();
|
||||||
expect(this.chatboxes.length).toEqual(2);
|
expect(converse.chatboxes.length).toEqual(2);
|
||||||
expect(chatboxview.focus).toHaveBeenCalled();
|
expect(chatboxview.focus).toHaveBeenCalled();
|
||||||
}.bind(this));
|
});
|
||||||
}.bind(converse));
|
});
|
||||||
|
|
||||||
it("can be saved to, and retrieved from, browserStorage", function () {
|
it("can be saved to, and retrieved from, browserStorage", function () {
|
||||||
spyOn(converse, 'emit');
|
spyOn(converse, 'emit');
|
||||||
@ -270,18 +269,19 @@
|
|||||||
}.bind(converse));
|
}.bind(converse));
|
||||||
|
|
||||||
it("contains a button for inserting emoticons", function () {
|
it("contains a button for inserting emoticons", function () {
|
||||||
var contact_jid = mock.cur_names[2].replace(/ /g,'.').toLowerCase() + '@localhost';
|
var contact_jid = mock.cur_names[2].replace(/ /g,'.').toLowerCase() + '@localhost',
|
||||||
test_utils.openChatBoxFor(contact_jid);
|
view, $toolbar, $textarea;
|
||||||
var view = this.chatboxviews.get(contact_jid);
|
waits(300); // ChatBox.show() is debounced for 250ms
|
||||||
var $toolbar = view.$el.find('ul.chat-toolbar');
|
|
||||||
var $textarea = view.$el.find('textarea.chat-textarea');
|
|
||||||
expect($toolbar.children('li.toggle-smiley').length).toBe(1);
|
|
||||||
// Register spies
|
|
||||||
spyOn(view, 'toggleEmoticonMenu').andCallThrough();
|
|
||||||
spyOn(view, 'insertEmoticon').andCallThrough();
|
|
||||||
view.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
|
|
||||||
|
|
||||||
runs(function () {
|
runs(function () {
|
||||||
|
test_utils.openChatBoxFor(contact_jid);
|
||||||
|
view = converse.chatboxviews.get(contact_jid);
|
||||||
|
$toolbar = view.$el.find('ul.chat-toolbar');
|
||||||
|
$textarea = view.$el.find('textarea.chat-textarea');
|
||||||
|
expect($toolbar.children('li.toggle-smiley').length).toBe(1);
|
||||||
|
// Register spies
|
||||||
|
spyOn(view, 'toggleEmoticonMenu').andCallThrough();
|
||||||
|
spyOn(view, 'insertEmoticon').andCallThrough();
|
||||||
|
view.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
|
||||||
$toolbar.children('li.toggle-smiley').click();
|
$toolbar.children('li.toggle-smiley').click();
|
||||||
});
|
});
|
||||||
waits(250);
|
waits(250);
|
||||||
@ -325,7 +325,7 @@
|
|||||||
expect(view.$el.find('.toggle-smiley ul').is(':visible')).toBeFalsy();
|
expect(view.$el.find('.toggle-smiley ul').is(':visible')).toBeFalsy();
|
||||||
expect($textarea.val()).toBe(':) <3 ');
|
expect($textarea.val()).toBe(':) <3 ');
|
||||||
});
|
});
|
||||||
}.bind(converse));
|
});
|
||||||
|
|
||||||
it("contains a button for starting an encrypted chat session", function () {
|
it("contains a button for starting an encrypted chat session", function () {
|
||||||
// TODO: More tests can be added here...
|
// TODO: More tests can be added here...
|
||||||
@ -812,17 +812,20 @@
|
|||||||
|
|
||||||
describe("An active notification", function () {
|
describe("An active notification", function () {
|
||||||
it("is sent when the user opens a chat box", function () {
|
it("is sent when the user opens a chat box", function () {
|
||||||
spyOn(converse.connection, 'send');
|
waits(300); // ChatBox.show() is debounced for 250ms
|
||||||
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
runs(function () {
|
||||||
test_utils.openChatBoxFor(contact_jid);
|
spyOn(converse.connection, 'send');
|
||||||
var view = this.chatboxviews.get(contact_jid);
|
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
expect(view.model.get('chat_state')).toBe('active');
|
test_utils.openChatBoxFor(contact_jid);
|
||||||
expect(converse.connection.send).toHaveBeenCalled();
|
var view = converse.chatboxviews.get(contact_jid);
|
||||||
var $stanza = $(converse.connection.send.argsForCall[0][0].tree());
|
expect(view.model.get('chat_state')).toBe('active');
|
||||||
expect($stanza.attr('to')).toBe(contact_jid);
|
expect(converse.connection.send).toHaveBeenCalled();
|
||||||
expect($stanza.children().length).toBe(1);
|
var $stanza = $(converse.connection.send.argsForCall[0][0].tree());
|
||||||
expect($stanza.children().prop('tagName')).toBe('active');
|
expect($stanza.attr('to')).toBe(contact_jid);
|
||||||
}.bind(converse));
|
expect($stanza.children().length).toBe(1);
|
||||||
|
expect($stanza.children().prop('tagName')).toBe('active');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("is sent when the user maximizes a minimized a chat box", function () {
|
it("is sent when the user maximizes a minimized a chat box", function () {
|
||||||
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
@ -843,30 +846,33 @@
|
|||||||
|
|
||||||
describe("A composing notification", function () {
|
describe("A composing notification", function () {
|
||||||
it("is sent as soon as the user starts typing a message which is not a command", function () {
|
it("is sent as soon as the user starts typing a message which is not a command", function () {
|
||||||
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
waits(300); // ChatBox.show() is debounced for 250ms
|
||||||
test_utils.openChatBoxFor(contact_jid);
|
runs(function () {
|
||||||
var view = this.chatboxviews.get(contact_jid);
|
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
expect(view.model.get('chat_state')).toBe('active');
|
test_utils.openChatBoxFor(contact_jid);
|
||||||
spyOn(this.connection, 'send');
|
var view = converse.chatboxviews.get(contact_jid);
|
||||||
view.keyPressed({
|
expect(view.model.get('chat_state')).toBe('active');
|
||||||
target: view.$el.find('textarea.chat-textarea'),
|
spyOn(converse.connection, 'send');
|
||||||
keyCode: 1
|
view.keyPressed({
|
||||||
});
|
target: view.$el.find('textarea.chat-textarea'),
|
||||||
expect(view.model.get('chat_state')).toBe('composing');
|
keyCode: 1
|
||||||
expect(this.connection.send).toHaveBeenCalled();
|
});
|
||||||
var $stanza = $(this.connection.send.argsForCall[0][0].tree());
|
expect(view.model.get('chat_state')).toBe('composing');
|
||||||
expect($stanza.attr('to')).toBe(contact_jid);
|
expect(converse.connection.send).toHaveBeenCalled();
|
||||||
expect($stanza.children().length).toBe(1);
|
var $stanza = $(converse.connection.send.argsForCall[0][0].tree());
|
||||||
expect($stanza.children().prop('tagName')).toBe('composing');
|
expect($stanza.attr('to')).toBe(contact_jid);
|
||||||
|
expect($stanza.children().length).toBe(1);
|
||||||
|
expect($stanza.children().prop('tagName')).toBe('composing');
|
||||||
|
|
||||||
// The notification is not sent again
|
// The notification is not sent again
|
||||||
view.keyPressed({
|
view.keyPressed({
|
||||||
target: view.$el.find('textarea.chat-textarea'),
|
target: view.$el.find('textarea.chat-textarea'),
|
||||||
keyCode: 1
|
keyCode: 1
|
||||||
|
});
|
||||||
|
expect(view.model.get('chat_state')).toBe('composing');
|
||||||
|
expect(converse.emit.callCount, 1);
|
||||||
});
|
});
|
||||||
expect(view.model.get('chat_state')).toBe('composing');
|
});
|
||||||
expect(converse.emit.callCount, 1);
|
|
||||||
}.bind(converse));
|
|
||||||
|
|
||||||
it("will be shown if received", function () {
|
it("will be shown if received", function () {
|
||||||
// See XEP-0085 http://xmpp.org/extensions/xep-0085.html#definitions
|
// See XEP-0085 http://xmpp.org/extensions/xep-0085.html#definitions
|
||||||
@ -893,13 +899,15 @@
|
|||||||
|
|
||||||
describe("A paused notification", function () {
|
describe("A paused notification", function () {
|
||||||
it("is sent if the user has stopped typing since 30 seconds", function () {
|
it("is sent if the user has stopped typing since 30 seconds", function () {
|
||||||
this.TIMEOUTS.PAUSED = 200; // Make the timeout shorter so that we can test
|
var view, contact_jid;
|
||||||
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
converse.TIMEOUTS.PAUSED = 200; // Make the timeout shorter so that we can test
|
||||||
test_utils.openChatBoxFor(contact_jid);
|
waits(300); // ChatBox.show() is debounced for 250ms
|
||||||
var view = this.chatboxviews.get(contact_jid);
|
|
||||||
spyOn(converse.connection, 'send');
|
|
||||||
spyOn(view, 'setChatState').andCallThrough();
|
|
||||||
runs(function () {
|
runs(function () {
|
||||||
|
contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
|
test_utils.openChatBoxFor(contact_jid);
|
||||||
|
view = converse.chatboxviews.get(contact_jid);
|
||||||
|
spyOn(converse.connection, 'send');
|
||||||
|
spyOn(view, 'setChatState').andCallThrough();
|
||||||
expect(view.model.get('chat_state')).toBe('active');
|
expect(view.model.get('chat_state')).toBe('active');
|
||||||
view.keyPressed({
|
view.keyPressed({
|
||||||
target: view.$el.find('textarea.chat-textarea'),
|
target: view.$el.find('textarea.chat-textarea'),
|
||||||
@ -940,7 +948,7 @@
|
|||||||
runs(function () {
|
runs(function () {
|
||||||
expect(view.model.get('chat_state')).toBe('composing');
|
expect(view.model.get('chat_state')).toBe('composing');
|
||||||
});
|
});
|
||||||
}.bind(converse));
|
});
|
||||||
|
|
||||||
it("will be shown if received", function () {
|
it("will be shown if received", function () {
|
||||||
// TODO: only show paused state if the previous state was composing
|
// TODO: only show paused state if the previous state was composing
|
||||||
@ -1010,19 +1018,22 @@
|
|||||||
}.bind(converse));
|
}.bind(converse));
|
||||||
|
|
||||||
it("is sent if the user closes a chat box", function () {
|
it("is sent if the user closes a chat box", function () {
|
||||||
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
waits(300); // ChatBox.show() is debounced for 250ms
|
||||||
test_utils.openChatBoxFor(contact_jid);
|
runs(function () {
|
||||||
var view = this.chatboxviews.get(contact_jid);
|
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
expect(view.model.get('chat_state')).toBe('active');
|
test_utils.openChatBoxFor(contact_jid);
|
||||||
spyOn(converse.connection, 'send');
|
var view = converse.chatboxviews.get(contact_jid);
|
||||||
view.close();
|
expect(view.model.get('chat_state')).toBe('active');
|
||||||
expect(view.model.get('chat_state')).toBe('inactive');
|
spyOn(converse.connection, 'send');
|
||||||
expect(converse.connection.send).toHaveBeenCalled();
|
view.close();
|
||||||
var $stanza = $(converse.connection.send.argsForCall[0][0].tree());
|
expect(view.model.get('chat_state')).toBe('inactive');
|
||||||
expect($stanza.attr('to')).toBe(contact_jid);
|
expect(converse.connection.send).toHaveBeenCalled();
|
||||||
expect($stanza.children().length).toBe(1);
|
var $stanza = $(converse.connection.send.argsForCall[0][0].tree());
|
||||||
expect($stanza.children().prop('tagName')).toBe('inactive');
|
expect($stanza.attr('to')).toBe(contact_jid);
|
||||||
}.bind(converse));
|
expect($stanza.children().length).toBe(1);
|
||||||
|
expect($stanza.children().prop('tagName')).toBe('inactive');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("will clear any other chat status notifications if its received", function () {
|
it("will clear any other chat status notifications if its received", function () {
|
||||||
// See XEP-0085 http://xmpp.org/extensions/xep-0085.html#definitions
|
// See XEP-0085 http://xmpp.org/extensions/xep-0085.html#definitions
|
||||||
|
195
spec/converse.js
195
spec/converse.js
@ -98,7 +98,7 @@
|
|||||||
it("happens when the client is idle for long enough", function () {
|
it("happens when the client is idle for long enough", function () {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
// Usually initialized by registerIntervalHandler
|
// Usually initialized by registerIntervalHandler
|
||||||
converse.idle_seconds = 0;
|
converse.idle_seconds = 0;
|
||||||
converse.auto_changed_status = false;
|
converse.auto_changed_status = false;
|
||||||
|
|
||||||
// The relevant config options
|
// The relevant config options
|
||||||
@ -265,15 +265,15 @@
|
|||||||
test_utils.createContacts('current');
|
test_utils.createContacts('current');
|
||||||
}, converse));
|
}, 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.
|
// Test on chat that doesn't exist.
|
||||||
expect(converse_api.chats.get('non-existing@jabber.org')).toBeFalsy();
|
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
|
// Test on chat that's not open
|
||||||
var jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
|
||||||
var box = converse_api.chats.get(jid);
|
var box = converse_api.chats.get(jid);
|
||||||
expect(box instanceof Object).toBeTruthy();
|
expect(box instanceof Object).toBeTruthy();
|
||||||
var chatboxview = this.chatboxviews.get(jid);
|
var chatboxview = converse.chatboxviews.get(jid);
|
||||||
expect(chatboxview.$el.is(':visible')).toBeFalsy();
|
expect(chatboxview.$el.is(':visible')).toBeFalsy();
|
||||||
|
|
||||||
// Test for single JID
|
// Test for single JID
|
||||||
@ -281,9 +281,8 @@
|
|||||||
box = converse_api.chats.get(jid);
|
box = converse_api.chats.get(jid);
|
||||||
expect(box instanceof Object).toBeTruthy();
|
expect(box instanceof Object).toBeTruthy();
|
||||||
expect(box.get('box_id')).toBe(b64_sha1(jid));
|
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();
|
expect(chatboxview.$el.is(':visible')).toBeTruthy();
|
||||||
|
|
||||||
// Test for multiple JIDs
|
// Test for multiple JIDs
|
||||||
var jid2 = mock.cur_names[1].replace(/ /g,'.').toLowerCase() + '@localhost';
|
var jid2 = mock.cur_names[1].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
test_utils.openChatBoxFor(jid2);
|
test_utils.openChatBoxFor(jid2);
|
||||||
@ -291,30 +290,32 @@
|
|||||||
expect(Array.isArray(list)).toBeTruthy();
|
expect(Array.isArray(list)).toBeTruthy();
|
||||||
expect(list[0].get('box_id')).toBe(b64_sha1(jid));
|
expect(list[0].get('box_id')).toBe(b64_sha1(jid));
|
||||||
expect(list[1].get('box_id')).toBe(b64_sha1(jid2));
|
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 jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
var box = converse_api.chats.open(jid);
|
var chatboxview;
|
||||||
expect(box instanceof Object).toBeTruthy();
|
waits('300'); // ChatBox.show() is debounced for 250ms
|
||||||
expect(box.get('box_id')).toBe(b64_sha1(jid));
|
runs(function () {
|
||||||
expect(
|
// Test on chat that doesn't exist.
|
||||||
Object.keys(box),
|
expect(converse_api.chats.get('non-existing@jabber.org')).toBeFalsy();
|
||||||
['close', 'endOTR', 'focus', 'get', 'initiateOTR', 'is_chatroom', 'maximize', 'minimize', 'open', 'set']
|
var box = converse_api.chats.open(jid);
|
||||||
);
|
expect(box instanceof Object).toBeTruthy();
|
||||||
var chatboxview = this.chatboxviews.get(jid);
|
expect(box.get('box_id')).toBe(b64_sha1(jid));
|
||||||
expect(chatboxview.$el.is(':visible')).toBeTruthy();
|
expect(
|
||||||
|
Object.keys(box),
|
||||||
// Test for multiple JIDs
|
['close', 'endOTR', 'focus', 'get', 'initiateOTR', 'is_chatroom', 'maximize', 'minimize', 'open', 'set']
|
||||||
var jid2 = mock.cur_names[1].replace(/ /g,'.').toLowerCase() + '@localhost';
|
);
|
||||||
var list = converse_api.chats.open([jid, jid2]);
|
chatboxview = converse.chatboxviews.get(jid);
|
||||||
expect(Array.isArray(list)).toBeTruthy();
|
expect(chatboxview.$el.is(':visible')).toBeTruthy();
|
||||||
expect(list[0].get('box_id')).toBe(b64_sha1(jid));
|
// Test for multiple JIDs
|
||||||
expect(list[1].get('box_id')).toBe(b64_sha1(jid2));
|
var jid2 = mock.cur_names[1].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
}, converse));
|
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));
|
}, converse));
|
||||||
|
|
||||||
describe("The \"rooms\" API", function () {
|
describe("The \"rooms\" API", function () {
|
||||||
@ -326,77 +327,91 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("has a method 'get' which returns a wrapped chat room (if it exists)", function () {
|
it("has a method 'get' which returns a wrapped chat room (if it exists)", function () {
|
||||||
test_utils.openChatRoom('lounge', 'localhost', 'dummy');
|
waits('300'); // ChatBox.show() is debounced for 250ms
|
||||||
var jid = 'lounge@localhost';
|
runs(function () {
|
||||||
var room = converse_api.rooms.get(jid);
|
test_utils.openChatRoom('lounge', 'localhost', 'dummy');
|
||||||
expect(room instanceof Object).toBeTruthy();
|
var jid = 'lounge@localhost';
|
||||||
expect(room.is_chatroom).toBeTruthy();
|
var room = converse_api.rooms.get(jid);
|
||||||
var chatroomview = converse.chatboxviews.get(jid);
|
expect(room instanceof Object).toBeTruthy();
|
||||||
expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
expect(room.is_chatroom).toBeTruthy();
|
||||||
chatroomview.close();
|
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();
|
||||||
|
|
||||||
// Test with mixed case
|
jid = 'leiSure@localhost';
|
||||||
test_utils.openChatRoom('Leisure', 'localhost', 'dummy');
|
room = converse_api.rooms.get(jid);
|
||||||
jid = 'Leisure@localhost';
|
expect(room instanceof Object).toBeTruthy();
|
||||||
room = converse_api.rooms.get(jid);
|
chatroomview = converse.chatboxviews.get(jid.toLowerCase());
|
||||||
expect(room instanceof Object).toBeTruthy();
|
expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
||||||
chatroomview = converse.chatboxviews.get(jid.toLowerCase());
|
chatroomview.close();
|
||||||
expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
|
||||||
|
|
||||||
jid = 'leisure@localhost';
|
// Non-existing room
|
||||||
room = converse_api.rooms.get(jid);
|
jid = 'lounge2@localhost';
|
||||||
expect(room instanceof Object).toBeTruthy();
|
room = converse_api.rooms.get(jid);
|
||||||
chatroomview = converse.chatboxviews.get(jid.toLowerCase());
|
expect(typeof room === 'undefined').toBeTruthy();
|
||||||
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 () {
|
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 jid = 'lounge@localhost';
|
||||||
var room = converse_api.rooms.open(jid);
|
var room = converse_api.rooms.open(jid);
|
||||||
expect(room instanceof Object).toBeTruthy();
|
runs(function () {
|
||||||
expect(room.is_chatroom).toBeTruthy();
|
// Test on chat room that doesn't exist.
|
||||||
var chatroomview = converse.chatboxviews.get(jid);
|
expect(room instanceof Object).toBeTruthy();
|
||||||
expect(chatroomview.$el.is(':visible')).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();
|
||||||
|
|
||||||
// Test again, now that the room exists.
|
jid = 'leisure@localhost';
|
||||||
room = converse_api.rooms.open(jid);
|
room = converse_api.rooms.open(jid);
|
||||||
expect(room instanceof Object).toBeTruthy();
|
expect(room instanceof Object).toBeTruthy();
|
||||||
expect(room.is_chatroom).toBeTruthy();
|
chatroomview = converse.chatboxviews.get(jid.toLowerCase());
|
||||||
chatroomview = converse.chatboxviews.get(jid);
|
expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
||||||
expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
|
||||||
|
|
||||||
// Test with mixed case in JID
|
jid = 'leiSure@localhost';
|
||||||
jid = 'Leisure@localhost';
|
room = converse_api.rooms.open(jid);
|
||||||
room = converse_api.rooms.open(jid);
|
expect(room instanceof Object).toBeTruthy();
|
||||||
expect(room instanceof Object).toBeTruthy();
|
chatroomview = converse.chatboxviews.get(jid.toLowerCase());
|
||||||
chatroomview = converse.chatboxviews.get(jid.toLowerCase());
|
expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
||||||
expect(chatroomview.$el.is(':visible')).toBeTruthy();
|
chatroomview.close();
|
||||||
|
});
|
||||||
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();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1429,7 +1429,7 @@
|
|||||||
converse.incrementMsgCounter();
|
converse.incrementMsgCounter();
|
||||||
}
|
}
|
||||||
if (!this.model.get('minimized') && !this.$el.is(':visible')) {
|
if (!this.model.get('minimized') && !this.$el.is(':visible')) {
|
||||||
_.debounce(this.show.bind(this), 100)();
|
this.show();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1830,7 +1830,7 @@
|
|||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
show: function (focus) {
|
show: _.debounce(function (callback) {
|
||||||
if (this.$el.is(':visible') && this.$el.css('opacity') === "1") {
|
if (this.$el.is(':visible') && this.$el.css('opacity') === "1") {
|
||||||
if (focus) { this.focus(); }
|
if (focus) { this.focus(); }
|
||||||
return this;
|
return this;
|
||||||
@ -1849,7 +1849,7 @@
|
|||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
return this;
|
return this;
|
||||||
},
|
}, 250, true),
|
||||||
|
|
||||||
scrollDownMessageHeight: function ($message) {
|
scrollDownMessageHeight: function ($message) {
|
||||||
if (this.$content.is(':visible')) {
|
if (this.$content.is(':visible')) {
|
||||||
|
Loading…
Reference in New Issue
Block a user