Small tweaks to tests to provide better visual feedback

This commit is contained in:
JC Brand 2013-04-19 21:03:26 +02:00
parent 399d029bd0
commit 9b445f8455

View File

@ -57,16 +57,24 @@
this.onConnected(mock_connection); this.onConnected(mock_connection);
this.animate = false; // don't use animations this.animate = false; // don't use animations
// Variable declarations for specs
var open_controlbox;
describe("The Control Box", $.proxy(function () { describe("The Control Box", $.proxy(function () {
it("is not shown by default", $.proxy(function () { it("is not shown by default", $.proxy(function () {
expect(this.rosterview.$el.is(':visible')).toEqual(false); expect(this.rosterview.$el.is(':visible')).toEqual(false);
}, xmppchat)); }, xmppchat));
it("can be opened by clicking a DOM element with class 'toggle-online-users'", $.proxy(function () { open_controlbox = $.proxy(function () {
// This spec will only pass if the controlbox is not currently
// open yet.
expect($("div#controlbox").is(':visible')).toBe(false);
spyOn(this, 'toggleControlBox').andCallThrough(); spyOn(this, 'toggleControlBox').andCallThrough();
$('.toggle-online-users').click(); $('.toggle-online-users').click();
expect(this.toggleControlBox).toHaveBeenCalled(); expect(this.toggleControlBox).toHaveBeenCalled();
}, xmppchat)); expect($("div#controlbox").is(':visible')).toBe(true);
}, xmppchat);
it("can be opened by clicking a DOM element with class 'toggle-online-users'", open_controlbox);
describe("The Status Widget", $.proxy(function () { describe("The Status Widget", $.proxy(function () {
it("can be used to set the current user's chat status", $.proxy(function () { it("can be used to set the current user's chat status", $.proxy(function () {
@ -98,14 +106,16 @@
spyOn(view, 'setStatusMessage').andCallThrough(); spyOn(view, 'setStatusMessage').andCallThrough();
spyOn(view, 'renderStatusChangeForm').andCallThrough(); spyOn(view, 'renderStatusChangeForm').andCallThrough();
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 () {
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();
}); // The async testing here is used only to provide time for
waits(250); // visual feedback
runs(function () {
var msg = 'I am happy'; var msg = 'I am happy';
runs (function () {
view.$el.find('form input.custom-xmpp-status').val(msg); view.$el.find('form input.custom-xmpp-status').val(msg);
});
waits(500);
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(view.$el.find('a.choose-xmpp-status').hasClass('online')).toBe(true); expect(view.$el.find('a.choose-xmpp-status').hasClass('online')).toBe(true);
@ -450,6 +460,9 @@
// in localStorage either. // in localStorage either.
newchatboxes.onConnected(); newchatboxes.onConnected();
expect(newchatboxes.length).toEqual(0); expect(newchatboxes.length).toEqual(0);
// Lets open the controlbox again, purely for visual feedback
open_controlbox();
}, xmppchat)); }, xmppchat));
describe("A Chat Message", $.proxy(function () { describe("A Chat Message", $.proxy(function () {