Commit 4950bb91 authored by JC Brand's avatar JC Brand

Fixing tests after latest refactoring

parent 99d9fbff
......@@ -13,7 +13,7 @@
runs(function () {
utils.closeAllChatBoxes();
utils.removeControlBox();
converse.roster.localStorage._clear();
converse.roster.browserStorage._clear();
utils.initConverse();
utils.createCurrentContacts();
utils.openControlBox();
......@@ -115,7 +115,7 @@
expect(chatboxview.focus).toHaveBeenCalled();
}, converse));
it("can be saved to, and retrieved from, localStorage", $.proxy(function () {
it("can be saved to, and retrieved from, browserStorage", $.proxy(function () {
spyOn(converse, 'emit');
spyOn(this.chatboxviews, 'trimChats');
runs(function () {
......@@ -129,11 +129,11 @@
// will be empty.
var newchatboxes = new this.ChatBoxes();
expect(newchatboxes.length).toEqual(0);
// The chatboxes will then be fetched from localStorage inside the
// The chatboxes will then be fetched from browserStorage inside the
// onConnected method
newchatboxes.onConnected();
expect(newchatboxes.length).toEqual(7);
// Check that the chatboxes items retrieved from localStorage
// Check that the chatboxes items retrieved from browserStorage
// have the same attributes values as the original ones.
attrs = ['id', 'box_id', 'visible'];
for (i=0; i<attrs.length; i++) {
......@@ -212,10 +212,10 @@
});
}.bind(converse));
it("will be removed from localStorage when closed", $.proxy(function () {
it("will be removed from browserStorage when closed", $.proxy(function () {
spyOn(converse, 'emit');
spyOn(converse.chatboxviews, 'trimChats');
this.chatboxes.localStorage._clear();
this.chatboxes.browserStorage._clear();
runs(function () {
utils.closeControlBox();
});
......@@ -235,9 +235,9 @@
expect(converse.emit).toHaveBeenCalledWith('onChatBoxClosed', jasmine.any(Object));
var newchatboxes = new this.ChatBoxes();
expect(newchatboxes.length).toEqual(0);
// onConnected will fetch chatboxes in localStorage, but
// onConnected will fetch chatboxes in browserStorage, but
// because there aren't any open chatboxes, there won't be any
// in localStorage either. XXX except for the controlbox
// in browserStorage either. XXX except for the controlbox
newchatboxes.onConnected();
expect(newchatboxes.length).toEqual(1);
expect(newchatboxes.models[0].id).toBe("controlbox");
......@@ -692,7 +692,7 @@
beforeEach(function () {
utils.closeAllChatBoxes();
utils.removeControlBox();
converse.roster.localStorage._clear();
converse.roster.browserStorage._clear();
utils.initConverse();
utils.createCurrentContacts();
utils.openControlBox();
......@@ -709,7 +709,7 @@
// (e.g for when this test is run on its own).
utils.sendMessage(view, message);
expect(view.model.messages.length > 0).toBeTruthy();
expect(view.model.messages.localStorage.records.length > 0).toBeTruthy();
expect(view.model.messages.browserStorage.records.length > 0).toBeTruthy();
expect(converse.emit).toHaveBeenCalledWith('onMessageSend', message);
message = '/clear';
......@@ -724,7 +724,7 @@
expect(view.clearMessages).toHaveBeenCalled();
expect(window.confirm).toHaveBeenCalled();
expect(view.model.messages.length, 0); // The messages must be removed from the chatbox
expect(view.model.messages.localStorage.records.length, 0); // And also from localStorage
expect(view.model.messages.browserStorage.records.length, 0); // And also from browserStorage
expect(converse.emit.callCount, 1);
expect(converse.emit.mostRecentCall.args, ['onMessageSend', message]);
}, converse));
......
......@@ -112,19 +112,19 @@
expect(converse.emit.callCount, 1);
}, converse));
it("can be saved to, and retrieved from, localStorage", $.proxy(function () {
it("can be saved to, and retrieved from, browserStorage", $.proxy(function () {
// We instantiate a new ChatBoxes collection, which by default
// will be empty.
spyOn(this.chatboxviews, 'trimChats');
utils.openControlBox();
var newchatboxes = new this.ChatBoxes();
expect(newchatboxes.length).toEqual(0);
// The chatboxes will then be fetched from localStorage inside the
// The chatboxes will then be fetched from browserStorage inside the
// onConnected method
newchatboxes.onConnected();
expect(this.chatboxviews.trimChats).toHaveBeenCalled();
expect(newchatboxes.length).toEqual(2); // XXX: Includes controlbox, is this a bug?
// Check that the chatrooms retrieved from localStorage
// Check that the chatrooms retrieved from browserStorage
// have the same attributes values as the original ones.
attrs = ['id', 'box_id', 'visible'];
for (i=0; i<attrs.length; i++) {
......
......@@ -42,12 +42,8 @@
describe("The Status Widget", $.proxy(function () {
beforeEach(function () {
runs(function () {
utils.openControlBox();
});
waits(250);
runs(function () {});
});
it("shows the user's chat status, which is online by default", $.proxy(function () {
var view = this.xmppstatusview;
......@@ -118,11 +114,11 @@
runs(function () {
utils.openControlBox();
});
waits(250);
waits(50);
runs(function () {
utils.openContactsPanel();
});
waits(250);
waits(50);
runs(function () {});
});
......@@ -210,12 +206,10 @@
runs(function () {
utils.openControlBox();
});
waits(250);
waits(50);
runs(function () {
utils.openContactsPanel();
});
waits(250);
runs(function () {});
}, converse));
it("do not have a heading if there aren't any", $.proxy(function () {
......@@ -436,19 +430,19 @@
}, converse));
describe("All Contacts", $.proxy(function () {
it("are saved to, and can be retrieved from, localStorage", $.proxy(function () {
it("are saved to, and can be retrieved from, browserStorage", $.proxy(function () {
var new_attrs, old_attrs, attrs, old_roster;
var num_contacts = this.roster.length;
new_roster = new this.RosterItems();
// Roster items are yet to be fetched from localStorage
// Roster items are yet to be fetched from browserStorage
expect(new_roster.length).toEqual(0);
new_roster.localStorage = new Backbone.LocalStorage(
new_roster.browserStorage = new Backbone.BrowserStorage.session(
b64_sha1('converse.rosteritems-dummy@localhost'));
new_roster.fetch();
expect(this.roster.length).toEqual(num_contacts);
// Check that the roster items retrieved from localStorage
expect(new_roster.length).toEqual(num_contacts);
// Check that the roster items retrieved from browserStorage
// have the same attributes values as the original ones.
attrs = ['jid', 'fullname', 'subscription', 'ask'];
for (i=0; i<attrs.length; i++) {
......@@ -463,7 +457,7 @@
}, converse));
afterEach($.proxy(function () {
// Contacts retrieved from localStorage have chat_status of
// Contacts retrieved from browserStorage have chat_status of
// "offline".
// In the next test suite, we need some online contacts, so
// we make some online now
......@@ -515,7 +509,7 @@
runs(function () {
utils.closeAllChatBoxes();
});
waits(250);
waits(50);
runs(function () {
utils.openControlBox();
});
......
......@@ -13,12 +13,12 @@
runs(function () {
utils.closeAllChatBoxes();
utils.removeControlBox();
converse.roster.localStorage._clear();
converse.roster.browserStorage._clear();
utils.initConverse();
utils.createCurrentContacts();
utils.openControlBox();
utils.openContactsPanel();
converse.minimized_chats.toggleview.model.localStorage._clear();
converse.minimized_chats.toggleview.model.browserStorage._clear();
converse.minimized_chats.initToggle();
});
});
......
......@@ -36,7 +36,7 @@
};
utils.initRoster = function () {
converse.roster.localStorage._clear();
converse.roster.browserStorage._clear();
converse.initRoster();
};
......@@ -93,7 +93,7 @@
var view = converse.chatboxviews.get(jid);
view.$el.find('.chat-content').empty();
view.model.messages.reset();
view.model.messages.localStorage._clear();
view.model.messages.browserStorage._clear();
};
utils.createCurrentContacts = function () {
......
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