2013-08-09 14:42:49 +02:00
|
|
|
var assert = require('assert');
|
|
|
|
|
2013-08-21 20:27:14 +02:00
|
|
|
add_dependencies({
|
|
|
|
_: 'third/underscore/underscore.js',
|
|
|
|
util: 'js/util.js',
|
|
|
|
Dict: 'js/dict.js'
|
|
|
|
});
|
2013-08-09 14:42:49 +02:00
|
|
|
|
2013-09-10 17:38:53 +02:00
|
|
|
set_global('$', function () {
|
|
|
|
return {
|
|
|
|
on: function () {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2013-09-16 18:22:52 +02:00
|
|
|
set_global('document', {
|
|
|
|
hasFocus: function () {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-08-21 20:27:14 +02:00
|
|
|
var activity = require('js/activity.js');
|
2013-08-09 14:42:49 +02:00
|
|
|
|
|
|
|
(function test_sort_users() {
|
|
|
|
var users = ['alice@zulip.com', 'fred@zulip.com', 'jill@zulip.com'];
|
|
|
|
|
|
|
|
var user_info = {
|
|
|
|
'alice@zulip.com': 'inactive',
|
|
|
|
'fred@zulip.com': 'active',
|
|
|
|
'jill@zulip.com': 'active'
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-08-21 20:27:14 +02:00
|
|
|
set_global('people_dict', new global.Dict.from({
|
2013-08-09 14:42:49 +02:00
|
|
|
'alice@zulip.com': 'Alice Smith',
|
|
|
|
'fred@zulip.com': 'Fred Flintstone',
|
|
|
|
'jill@zulip.com': 'Jill Hill'
|
2013-08-21 20:27:14 +02:00
|
|
|
}));
|
2013-08-09 14:42:49 +02:00
|
|
|
|
|
|
|
activity._sort_users(users, user_info);
|
|
|
|
|
|
|
|
assert.deepEqual(users, [
|
|
|
|
'fred@zulip.com',
|
|
|
|
'jill@zulip.com',
|
|
|
|
'alice@zulip.com'
|
|
|
|
]);
|
|
|
|
}());
|