Add toggle test for chatrooms
This commit is contained in:
parent
b552b885f0
commit
6290f954a7
@ -132,6 +132,39 @@
|
||||
this.rosterview.render();
|
||||
}, converse));
|
||||
|
||||
it("can be toggled 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, 'toggleChatBox').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);
|
||||
runs(function () {
|
||||
expect(view.toggleChatBox).toHaveBeenCalled();
|
||||
expect(converse.emit).toHaveBeenCalledWith('onChatBoxToggled', 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.model.get('minimized')).toBeTruthy();
|
||||
view.$el.find('.toggle-chatbox-button').click();
|
||||
});
|
||||
waits(250);
|
||||
runs(function () {
|
||||
expect(view.toggleChatBox).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.model.get('minimized')).toBeFalsy();
|
||||
expect(converse.emit.callCount, 3);
|
||||
});
|
||||
}.bind(converse));
|
||||
|
||||
|
||||
it("can be closed again by clicking a DOM element with class 'close-chatbox-button'", $.proxy(function () {
|
||||
var view = this.chatboxviews.get('lounge@muc.localhost'), chatroom = view.model, $el;
|
||||
spyOn(view, 'closeChat').andCallThrough();
|
||||
|
Loading…
Reference in New Issue
Block a user