Commit 278c2c42 authored by JC Brand's avatar JC Brand

Add tests for the live filter functionality. updates #212

parent 71069790
...@@ -3479,7 +3479,7 @@ ...@@ -3479,7 +3479,7 @@
var t = this.$('.filter-type').val(); var t = this.$('.filter-type').val();
$(ev.target)[this.tog(q)]('x'); $(ev.target)[this.tog(q)]('x');
this.filter(q, t); this.filter(q, t);
}, 500), }, 300),
clearFilter: function (ev) { clearFilter: function (ev) {
if (ev && ev.preventDefault) { if (ev && ev.preventDefault) {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
test_utils.removeControlBox(); test_utils.removeControlBox();
test_utils.clearBrowserStorage(); test_utils.clearBrowserStorage();
test_utils.initConverse(); test_utils.initConverse();
test_utils.createContacts(); test_utils.createContacts('current');
test_utils.openControlBox(); test_utils.openControlBox();
test_utils.openContactsPanel(); test_utils.openContactsPanel();
}); });
...@@ -684,7 +684,7 @@ ...@@ -684,7 +684,7 @@
test_utils.removeControlBox(); test_utils.removeControlBox();
converse.roster.browserStorage._clear(); converse.roster.browserStorage._clear();
test_utils.initConverse(); test_utils.initConverse();
test_utils.createContacts(); test_utils.createContacts('current');
test_utils.openControlBox(); test_utils.openControlBox();
test_utils.openContactsPanel(); test_utils.openContactsPanel();
}); });
......
This diff is collapsed.
...@@ -8,14 +8,13 @@ ...@@ -8,14 +8,13 @@
); );
} (this, function (mock, test_utils) { } (this, function (mock, test_utils) {
return describe("The Minimized Chats Widget", $.proxy(function(mock, test_utils) { return describe("The Minimized Chats Widget", $.proxy(function(mock, test_utils) {
beforeEach(function () { beforeEach(function () {
runs(function () { runs(function () {
test_utils.closeAllChatBoxes(); test_utils.closeAllChatBoxes();
test_utils.removeControlBox(); test_utils.removeControlBox();
converse.roster.browserStorage._clear(); converse.roster.browserStorage._clear();
test_utils.initConverse(); test_utils.initConverse();
test_utils.createContacts(); test_utils.createContacts('current');
test_utils.openControlBox(); test_utils.openControlBox();
test_utils.openContactsPanel(); test_utils.openContactsPanel();
converse.minimized_chats.toggleview.model.browserStorage._clear(); converse.minimized_chats.toggleview.model.browserStorage._clear();
......
...@@ -20,6 +20,14 @@ ...@@ -20,6 +20,14 @@
]; ];
mock.num_contacts = mock.req_names.length + mock.pend_names.length + mock.cur_names.length; mock.num_contacts = mock.req_names.length + mock.pend_names.length + mock.cur_names.length;
mock.groups = {
'colleagues': 3,
'friends & acquaintences': 3,
'Family': 4,
'ænemies': 3,
'Ungrouped': 2
};
mock.chatroom_names = [ mock.chatroom_names = [
'Dyon van de Wege', 'Thomas Kalb', 'Dirk Theissen', 'Felix Hofmann', 'Ka Lek', 'Anne Ebersbacher' 'Dyon van de Wege', 'Thomas Kalb', 'Dirk Theissen', 'Felix Hofmann', 'Ka Lek', 'Anne Ebersbacher'
]; ];
......
...@@ -110,9 +110,12 @@ ...@@ -110,9 +110,12 @@
view.model.messages.browserStorage._clear(); view.model.messages.browserStorage._clear();
}; };
utils.createContacts = function (type) { utils.createContacts = function (type, length) {
// Create current (as opposed to requesting or pending) contacts /* Create current (as opposed to requesting or pending) contacts
// for the user's roster. * for the user's roster.
*
* These contacts are not grouped. See below.
*/
var names; var names;
if (type === 'requesting') { if (type === 'requesting') {
names = mock.req_names; names = mock.req_names;
...@@ -124,16 +127,22 @@ ...@@ -124,16 +127,22 @@
subscription = 'none'; subscription = 'none';
requesting = false; requesting = false;
ask = 'subscribe'; ask = 'subscribe';
} else if (type === 'all') { } else if (type === 'current') {
this.createContacts().createContacts('request').createContacts('pending');
return this;
} else {
names = mock.cur_names; names = mock.cur_names;
subscription = 'both'; subscription = 'both';
requesting = false; requesting = false;
ask = null; ask = null;
} else if (type === 'all') {
this.createContacts('current').createContacts('requesting').createContacts('pending');
return this;
} else {
throw "Need to specify the type of contact to create";
} }
for (i=0; i<names.length; i++) {
if (typeof length === 'undefined') {
length = names.length;
}
for (i=0; i<length; i++) {
converse.roster.create({ converse.roster.create({
ask: ask, ask: ask,
fullname: names[i], fullname: names[i],
...@@ -145,6 +154,24 @@ ...@@ -145,6 +154,24 @@
return this; return this;
}; };
utils.createGroupedContacts = function () {
/* Create grouped contacts
*/
var i=0, j=0;
_.each(_.keys(mock.groups), $.proxy(function (name) {
j = i;
for (i=j; i<j+mock.groups[name]; i++) {
converse.roster.create({
jid: mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost',
subscription: 'both',
ask: null,
groups: name === 'ungrouped'? [] : [name],
fullname: mock.cur_names[i]
});
}
}, converse));
};
utils.sendMessage = function (chatboxview, message) { utils.sendMessage = function (chatboxview, message) {
chatboxview.$el.find('.chat-textarea').val(message); chatboxview.$el.find('.chat-textarea').val(message);
chatboxview.$el.find('textarea.chat-textarea').trigger($.Event('keypress', {keyCode: 13})); chatboxview.$el.find('textarea.chat-textarea').trigger($.Event('keypress', {keyCode: 13}));
......
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