Commit 44fe406a authored by JC Brand's avatar JC Brand

Refactored tests.

Split MainSpec out into ChatBoxSpec and ControlBoxSpec.

Part of trying to have looser coupling between tests so that they can be run
independently.
parent b0f12d0f
This diff is collapsed.
...@@ -9,10 +9,11 @@ ...@@ -9,10 +9,11 @@
} (this, function (mock, utils) { } (this, function (mock, utils) {
return describe("ChatRooms", $.proxy(function (mock, utils) { return describe("ChatRooms", $.proxy(function (mock, utils) {
describe("A Chat Room", $.proxy(function () { describe("A Chat Room", $.proxy(function () {
beforeEach($.proxy(function () { beforeEach($.proxy(function () {
if (!$("div#controlbox").is(':visible')) { utils.closeAllChatBoxes();
$('.toggle-online-users').click(); utils.openControlBox();
} utils.openRoomsPanel();
var roomspanel = this.chatboxesview.views.controlbox.roomspanel; var roomspanel = this.chatboxesview.views.controlbox.roomspanel;
var $input = roomspanel.$el.find('input.new-chatroom-name'); var $input = roomspanel.$el.find('input.new-chatroom-name');
var $nick = roomspanel.$el.find('input.new-chatroom-nick'); var $nick = roomspanel.$el.find('input.new-chatroom-nick');
......
This diff is collapsed.
This diff is collapsed.
(function (root, factory) { (function (root, factory) {
define("utils", ['jquery'], define("utils", [
function($) { 'jquery',
return factory($); 'mock'
],
function($, mock) {
return factory($, mock);
}); });
}(this, function ($) { }(this, function ($, mock) {
var utils = {}; var utils = {};
utils.closeAllChatBoxes = function () { utils.closeAllChatBoxes = function () {
...@@ -45,14 +48,22 @@ ...@@ -45,14 +48,22 @@
$tabs.find('li').first().find('a').click(); $tabs.find('li').first().find('a').click();
}; };
utils.createContactsRoster = function () { utils.openRoomsPanel = function () {
for (i=0; i<cur_names.length; i++) { var cbview = converse.chatboxesview.views.controlbox;
this.roster.create({ var $tabs = cbview.$el.find('#controlbox-tabs');
jid: cur_names[i].replace(' ','.').toLowerCase() + '@localhost', $tabs.find('li').last().find('a').click();
};
utils.createCurrentContacts = function () {
// Create current (as opposed to requesting or pending) contacts
// for the user's roster.
for (i=0; i<mock.cur_names.length; i++) {
converse.roster.create({
jid: mock.cur_names[i].replace(' ','.').toLowerCase() + '@localhost',
subscription: 'both', subscription: 'both',
ask: null, ask: null,
fullname: cur_names[i], fullname: mock.cur_names[i],
is_last: i===(cur_names.length-1) is_last: i===(mock.cur_names.length-1)
}); });
} }
return this; return this;
......
...@@ -102,7 +102,8 @@ require([ ...@@ -102,7 +102,8 @@ require([
require([ require([
"jasmine-console-reporter", "jasmine-console-reporter",
"jasmine-junit-reporter", "jasmine-junit-reporter",
"spec/MainSpec", "spec/ControlBoxSpec",
"spec/ChatBoxSpec",
"spec/ChatRoomSpec" "spec/ChatRoomSpec"
], function () { ], function () {
// Jasmine stuff // Jasmine stuff
...@@ -119,7 +120,7 @@ require([ ...@@ -119,7 +120,7 @@ require([
jasmineEnv.specFilter = function(spec) { jasmineEnv.specFilter = function(spec) {
return htmlReporter.specFilter(spec); return htmlReporter.specFilter(spec);
}; };
jasmineEnv.updateInterval = 20; jasmineEnv.updateInterval = 100;
} }
jasmineEnv.execute(); jasmineEnv.execute();
}); });
......
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