Extend the "close chat" test with a normal chatbox usecase
This commit is contained in:
parent
c030494ef0
commit
ac0042fdf9
@ -2537,7 +2537,7 @@
|
|||||||
|
|
||||||
openChat: function (ev) {
|
openChat: function (ev) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
converse.chatboxesview.showChatBox({
|
return converse.chatboxesview.showChatBox({
|
||||||
'id': this.model.get('jid'),
|
'id': this.model.get('jid'),
|
||||||
'jid': this.model.get('jid'),
|
'jid': this.model.get('jid'),
|
||||||
'fullname': this.model.get('fullname'),
|
'fullname': this.model.get('fullname'),
|
||||||
|
@ -77,21 +77,34 @@
|
|||||||
}.bind(converse));
|
}.bind(converse));
|
||||||
}, converse));
|
}, converse));
|
||||||
|
|
||||||
it("can be closed again by clicking a DOM element with class 'close-chatbox-button'", $.proxy(function () {
|
it("can be closed by clicking a DOM element with class 'close-chatbox-button'", $.proxy(function () {
|
||||||
|
var chatbox = utils.openChatBoxes(1)[0],
|
||||||
|
controlview = this.chatboxesview.views.controlbox, // The controlbox is currently open
|
||||||
|
chatview = this.chatboxesview.views[chatbox.get('jid')];
|
||||||
|
spyOn(chatview, 'closeChat').andCallThrough();
|
||||||
|
spyOn(controlview, 'closeChat').andCallThrough();
|
||||||
spyOn(converse, 'emit');
|
spyOn(converse, 'emit');
|
||||||
var view = this.chatboxesview.views.controlbox; // The controlbox is currently open
|
|
||||||
spyOn(view, 'closeChat').andCallThrough();
|
// We need to rebind all events otherwise our spy won't be called
|
||||||
view.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
|
controlview.delegateEvents();
|
||||||
|
chatview.delegateEvents();
|
||||||
|
|
||||||
runs(function () {
|
runs(function () {
|
||||||
view.$el.find('.close-chatbox-button').click();
|
controlview.$el.find('.close-chatbox-button').click();
|
||||||
});
|
});
|
||||||
waits(250);
|
waits(250);
|
||||||
runs(function () {
|
runs(function () {
|
||||||
expect(view.closeChat).toHaveBeenCalled();
|
expect(controlview.closeChat).toHaveBeenCalled();
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onChatBoxClosed', jasmine.any(Object));
|
expect(converse.emit).toHaveBeenCalledWith('onChatBoxClosed', jasmine.any(Object));
|
||||||
|
expect(converse.emit.callCount, 1);
|
||||||
|
chatview.$el.find('.close-chatbox-button').click();
|
||||||
|
});
|
||||||
|
waits(250);
|
||||||
|
runs(function () {
|
||||||
|
expect(chatview.closeChat).toHaveBeenCalled();
|
||||||
|
expect(converse.emit).toHaveBeenCalledWith('onChatBoxClosed', jasmine.any(Object));
|
||||||
|
expect(converse.emit.callCount, 2);
|
||||||
});
|
});
|
||||||
// TODO: Open a normal chatbox and close it again...
|
|
||||||
}, converse));
|
}, converse));
|
||||||
|
|
||||||
it("will be removed from localStorage when closed", $.proxy(function () {
|
it("will be removed from localStorage when closed", $.proxy(function () {
|
||||||
|
@ -78,11 +78,12 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
utils.openChatBoxes = function (amount) {
|
utils.openChatBoxes = function (amount) {
|
||||||
var i = 0, jid;
|
var i = 0, jid, views = [];
|
||||||
for (i; i<amount; i++) {
|
for (i; i<amount; i++) {
|
||||||
jid = mock.cur_names[i].replace(' ','.').toLowerCase() + '@localhost';
|
jid = mock.cur_names[i].replace(' ','.').toLowerCase() + '@localhost';
|
||||||
converse.rosterview.rosteritemviews[jid].openChat(mock.event);
|
views[i] = converse.rosterview.rosteritemviews[jid].openChat(mock.event);
|
||||||
}
|
}
|
||||||
|
return views;
|
||||||
};
|
};
|
||||||
|
|
||||||
utils.openChatBoxFor = function (jid) {
|
utils.openChatBoxFor = function (jid) {
|
||||||
|
Loading…
Reference in New Issue
Block a user