2013-05-11 14:20:07 +02:00
|
|
|
(function (root, factory) {
|
2013-07-25 09:45:35 +02:00
|
|
|
define("mock",
|
|
|
|
['converse'],
|
2015-02-01 16:15:34 +01:00
|
|
|
function(converse) {
|
|
|
|
return factory(converse);
|
2013-05-11 14:20:07 +02:00
|
|
|
});
|
|
|
|
}(this, function (converse) {
|
2015-02-01 16:15:34 +01:00
|
|
|
var Strophe = converse.env.Strophe;
|
|
|
|
var $iq = converse.env.$iq;
|
2013-11-02 09:56:20 +01:00
|
|
|
var mock = {};
|
|
|
|
// Names from http://www.fakenamegenerator.com/
|
|
|
|
mock.req_names = [
|
|
|
|
'Louw Spekman', 'Mohamad Stet', 'Dominik Beyer'
|
|
|
|
];
|
|
|
|
mock.pend_names = [
|
|
|
|
'Suleyman van Beusichem', 'Nanja van Yperen', 'Nicole Diederich'
|
|
|
|
];
|
|
|
|
mock.cur_names = [
|
|
|
|
'Max Frankfurter', 'Candice van der Knijff', 'Irini Vlastuin', 'Rinse Sommer', 'Annegreet Gomez',
|
|
|
|
'Robin Schook', 'Marcel Eberhardt', 'Simone Brauer', 'Asmaa Haakman', 'Felix Amsel',
|
|
|
|
'Lena Grunewald', 'Laura Grunewald', 'Mandy Seiler', 'Sven Bosch', 'Nuriye Cuypers'
|
|
|
|
];
|
|
|
|
mock.num_contacts = mock.req_names.length + mock.pend_names.length + mock.cur_names.length;
|
|
|
|
|
2014-08-18 20:37:38 +02:00
|
|
|
mock.groups = {
|
|
|
|
'colleagues': 3,
|
|
|
|
'friends & acquaintences': 3,
|
|
|
|
'Family': 4,
|
|
|
|
'ænemies': 3,
|
|
|
|
'Ungrouped': 2
|
|
|
|
};
|
|
|
|
|
2013-11-02 09:56:20 +01:00
|
|
|
mock.chatroom_names = [
|
|
|
|
'Dyon van de Wege', 'Thomas Kalb', 'Dirk Theissen', 'Felix Hofmann', 'Ka Lek', 'Anne Ebersbacher'
|
|
|
|
];
|
|
|
|
|
2013-11-03 10:36:31 +01:00
|
|
|
mock.event = {
|
|
|
|
'preventDefault': function () {}
|
|
|
|
};
|
|
|
|
|
2014-10-24 18:58:42 +02:00
|
|
|
mock.mock_connection = function () {
|
|
|
|
Strophe.Bosh.prototype._processRequest = function () {}; // Don't attempt to send out stanzas
|
|
|
|
var c = new Strophe.Connection('jasmine tests');
|
|
|
|
c.authenticated = true;
|
|
|
|
c.connected = true;
|
|
|
|
c.mock = true;
|
|
|
|
c.jid = 'dummy@localhost/resource';
|
|
|
|
c.vcard = {
|
|
|
|
'get': function (callback, jid) {
|
|
|
|
var fullname;
|
|
|
|
if (!jid) {
|
|
|
|
jid = 'dummy@localhost';
|
|
|
|
fullname = 'Max Mustermann' ;
|
|
|
|
} else {
|
|
|
|
var name = jid.split('@')[0].replace(/\./g, ' ').split(' ');
|
|
|
|
var last = name.length-1;
|
|
|
|
name[0] = name[0].charAt(0).toUpperCase()+name[0].slice(1);
|
|
|
|
name[last] = name[last].charAt(0).toUpperCase()+name[last].slice(1);
|
|
|
|
fullname = name.join(' ');
|
|
|
|
}
|
|
|
|
var vcard = $iq().c('vCard').c('FN').t(fullname);
|
|
|
|
callback(vcard.tree());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
c._changeConnectStatus(Strophe.Status.CONNECTED);
|
|
|
|
c.attach(c.jid);
|
|
|
|
return c;
|
|
|
|
}();
|
2013-11-02 09:56:20 +01:00
|
|
|
return mock;
|
2013-05-11 14:20:07 +02:00
|
|
|
}));
|