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 @@
var t = this.$('.filter-type').val();
$(ev.target)[this.tog(q)]('x');
this.filter(q, t);
}, 500),
}, 300),
clearFilter: function (ev) {
if (ev && ev.preventDefault) {
......
......@@ -15,7 +15,7 @@
test_utils.removeControlBox();
test_utils.clearBrowserStorage();
test_utils.initConverse();
test_utils.createContacts();
test_utils.createContacts('current');
test_utils.openControlBox();
test_utils.openContactsPanel();
});
......@@ -684,7 +684,7 @@
test_utils.removeControlBox();
converse.roster.browserStorage._clear();
test_utils.initConverse();
test_utils.createContacts();
test_utils.createContacts('current');
test_utils.openControlBox();
test_utils.openContactsPanel();
});
......
This diff is collapsed.
......@@ -8,14 +8,13 @@
);
} (this, function (mock, test_utils) {
return describe("The Minimized Chats Widget", $.proxy(function(mock, test_utils) {
beforeEach(function () {
runs(function () {
test_utils.closeAllChatBoxes();
test_utils.removeControlBox();
converse.roster.browserStorage._clear();
test_utils.initConverse();
test_utils.createContacts();
test_utils.createContacts('current');
test_utils.openControlBox();
test_utils.openContactsPanel();
converse.minimized_chats.toggleview.model.browserStorage._clear();
......
......@@ -20,6 +20,14 @@
];
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 = [
'Dyon van de Wege', 'Thomas Kalb', 'Dirk Theissen', 'Felix Hofmann', 'Ka Lek', 'Anne Ebersbacher'
];
......
......@@ -110,9 +110,12 @@
view.model.messages.browserStorage._clear();
};
utils.createContacts = function (type) {
// Create current (as opposed to requesting or pending) contacts
// for the user's roster.
utils.createContacts = function (type, length) {
/* Create current (as opposed to requesting or pending) contacts
* for the user's roster.
*
* These contacts are not grouped. See below.
*/
var names;
if (type === 'requesting') {
names = mock.req_names;
......@@ -124,16 +127,22 @@
subscription = 'none';
requesting = false;
ask = 'subscribe';
} else if (type === 'all') {
this.createContacts().createContacts('request').createContacts('pending');
return this;
} else {
} else if (type === 'current') {
names = mock.cur_names;
subscription = 'both';
requesting = false;
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({
ask: ask,
fullname: names[i],
......@@ -145,6 +154,24 @@
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) {
chatboxview.$el.find('.chat-textarea').val(message);
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