Fix chatroom tests

This commit is contained in:
JC Brand 2014-06-02 05:13:53 +02:00
parent ef9fd9617d
commit c6a32b847e
3 changed files with 26 additions and 22 deletions

View File

@ -1314,6 +1314,7 @@
} else {
this.model.trigger('hide');
}
converse.emit('onChatBoxClosed', this);
return this;
},
@ -1323,6 +1324,7 @@
this.$el.insertAfter(converse.chatboxviews.get("controlbox").$el).show();
this.focus();
converse.refreshWebkit();
converse.emit('onChatBoxMaximized', this);
this.model.trigger('maximized', this.model);
},
@ -1334,7 +1336,7 @@
'time_minimized': moment().format()
});
this.$el.hide('fast', converse.refreshwebkit);
converse.emit('onChatBoxToggled', this);
converse.emit('onChatBoxMinimized', this);
},
updateVCard: function () {

View File

@ -181,12 +181,12 @@
});
}, converse));
it("can be toggled by clicking a DOM element with class 'toggle-chatbox-button'", function () {
it("can be minimized by clicking a DOM element with class 'toggle-chatbox-button'", function () {
var chatbox = utils.openChatBoxes(1)[0],
chatview = this.chatboxviews.get(chatbox.get('jid')),
trimmed_chatboxes = this.chatboxviews.trimmed_chatboxes_view;
spyOn(chatview, 'maximize').andCallThrough();
spyOn(chatview, 'toggle').andCallThrough();
spyOn(chatview, 'minimize').andCallThrough();
spyOn(converse, 'emit');
spyOn(trimmed_chatboxes, 'onChanged').andCallThrough();
// We need to rebind all events otherwise our spy won't be called
@ -197,8 +197,8 @@
});
waits(50);
runs(function () {
expect(chatview.toggle).toHaveBeenCalled();
expect(converse.emit).toHaveBeenCalledWith('onChatBoxToggled', jasmine.any(Object));
expect(chatview.minimize).toHaveBeenCalled();
expect(converse.emit).toHaveBeenCalledWith('onChatBoxMinimized', jasmine.any(Object));
expect(converse.emit.callCount, 2);
expect(chatview.$el.is(':visible')).toBeFalsy();
expect(chatview.model.get('minimized')).toBeTruthy();
@ -211,6 +211,7 @@
runs(function () {
expect(trimmed_chatboxes.onChanged).toHaveBeenCalled();
expect(chatview.maximize).toHaveBeenCalled();
expect(converse.emit).toHaveBeenCalledWith('onChatBoxMaximized', jasmine.any(Object));
expect(chatview.$el.find('.chat-body').is(':visible')).toBeTruthy();
expect(chatview.$el.find('.toggle-chatbox-button').hasClass('icon-minus')).toBeTruthy();
expect(chatview.$el.find('.toggle-chatbox-button').hasClass('icon-plus')).toBeFalsy();

View File

@ -139,33 +139,34 @@
this.rosterview.render();
}, converse));
it("can be toggled by clicking a DOM element with class 'toggle-chatbox-button'", function () {
it("can be minimized by clicking a DOM element with class 'toggle-chatbox-button'", function () {
var view = this.chatboxviews.get('lounge@muc.localhost'),
chatroom = view.model, $el;
spyOn(view, 'toggle').andCallThrough();
trimmed_chatboxes = this.chatboxviews.trimmed_chatboxes_view;
spyOn(view, 'minimize').andCallThrough();
spyOn(view, 'maximize').andCallThrough();
spyOn(converse, 'emit');
view.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
runs(function () {
view.$el.find('.toggle-chatbox-button').click();
});
waits(250);
waits(50);
runs(function () {
expect(view.toggle).toHaveBeenCalled();
expect(converse.emit).toHaveBeenCalledWith('onChatBoxToggled', jasmine.any(Object));
expect(view.minimize).toHaveBeenCalled();
expect(converse.emit).toHaveBeenCalledWith('onChatBoxMinimized', jasmine.any(Object));
expect(converse.emit.callCount, 2);
expect(view.$el.find('.chat-body').is(':visible')).toBeFalsy();
expect(view.$el.find('.toggle-chatbox-button').hasClass('icon-minus')).toBeFalsy();
expect(view.$el.find('.toggle-chatbox-button').hasClass('icon-plus')).toBeTruthy();
expect(view.$el.is(':visible')).toBeFalsy();
expect(view.model.get('minimized')).toBeTruthy();
view.$el.find('.toggle-chatbox-button').click();
expect(view.minimize).toHaveBeenCalled();
trimmedview = trimmed_chatboxes.get(view.model.get('id'));
trimmedview.$("a.restore-chat").click();
});
waits(250);
waits(50);
runs(function () {
expect(view.toggle).toHaveBeenCalled();
expect(converse.emit).toHaveBeenCalledWith('onChatBoxToggled', jasmine.any(Object));
expect(view.$el.find('.chat-body').is(':visible')).toBeTruthy();
expect(view.$el.find('.toggle-chatbox-button').hasClass('icon-minus')).toBeTruthy();
expect(view.$el.find('.toggle-chatbox-button').hasClass('icon-plus')).toBeFalsy();
expect(view.maximize).toHaveBeenCalled();
expect(converse.emit).toHaveBeenCalledWith('onChatBoxMaximized', jasmine.any(Object));
expect(view.$el.is(':visible')).toBeTruthy();
expect(view.model.get('minimized')).toBeFalsy();
expect(converse.emit.callCount, 3);
});
@ -181,7 +182,7 @@
runs(function () {
view.$el.find('.close-chatbox-button').click();
});
waits(250);
waits(50);
runs(function () {
expect(view.close).toHaveBeenCalled();
expect(this.connection.muc.leave).toHaveBeenCalled();