Commit 1939ddac authored by JC Brand's avatar JC Brand

Test events emitted when own status or status message is changed. Updates #48

parent 9a8975f5
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
var view = this.xmppstatusview; var view = this.xmppstatusview;
spyOn(view, 'toggleOptions').andCallThrough(); spyOn(view, 'toggleOptions').andCallThrough();
spyOn(view, 'setStatus').andCallThrough(); spyOn(view, 'setStatus').andCallThrough();
spyOn(converse, 'emit');
view.delegateEvents(); // 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
runs(function () { runs(function () {
view.$el.find('a.choose-xmpp-status').click(); view.$el.find('a.choose-xmpp-status').click();
...@@ -49,8 +50,9 @@ ...@@ -49,8 +50,9 @@
runs(function () { runs(function () {
spyOn(view, 'updateStatusUI').andCallThrough(); spyOn(view, 'updateStatusUI').andCallThrough();
view.initialize(); // Rebind events for spy view.initialize(); // Rebind events for spy
$(view.$el.find('.dropdown dd ul li a')[1]).click(); $(view.$el.find('.dropdown dd ul li a')[1]).click(); // Change status to "dnd"
expect(view.setStatus).toHaveBeenCalled(); expect(view.setStatus).toHaveBeenCalled();
expect(converse.emit).toHaveBeenCalledWith('onStatusChanged', 'dnd');
}); });
waits(250); waits(250);
runs($.proxy(function () { runs($.proxy(function () {
...@@ -66,6 +68,7 @@ ...@@ -66,6 +68,7 @@
this.xmppstatus.save({'status': 'online'}); this.xmppstatus.save({'status': 'online'});
spyOn(view, 'setStatusMessage').andCallThrough(); spyOn(view, 'setStatusMessage').andCallThrough();
spyOn(view, 'renderStatusChangeForm').andCallThrough(); spyOn(view, 'renderStatusChangeForm').andCallThrough();
spyOn(converse, 'emit');
view.delegateEvents(); // 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
view.$el.find('a.change-xmpp-status-message').click(); view.$el.find('a.change-xmpp-status-message').click();
expect(view.renderStatusChangeForm).toHaveBeenCalled(); expect(view.renderStatusChangeForm).toHaveBeenCalled();
...@@ -79,6 +82,7 @@ ...@@ -79,6 +82,7 @@
runs (function () { runs (function () {
view.$el.find('form#set-custom-xmpp-status').submit(); view.$el.find('form#set-custom-xmpp-status').submit();
expect(view.setStatusMessage).toHaveBeenCalled(); expect(view.setStatusMessage).toHaveBeenCalled();
expect(converse.emit).toHaveBeenCalledWith('onStatusMessageChanged', msg);
expect(view.$el.find('a.choose-xmpp-status').hasClass('online')).toBe(true); expect(view.$el.find('a.choose-xmpp-status').hasClass('online')).toBe(true);
expect(view.$el.find('a.choose-xmpp-status').attr('data-value')).toBe(msg); expect(view.$el.find('a.choose-xmpp-status').attr('data-value')).toBe(msg);
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment