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

Fixing tests after latest refactoring

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