mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 00:46:03 +00:00
The functions add_dependencies() and set_global() are convenience methods that allow you to modify the global namespace while the current file is running but then have it be cleaned up by index.js when you're done. (imported from commit f75b8a10c19f773a8d2d3a8fa4bc39b1679566fe)
35 lines
788 B
JavaScript
35 lines
788 B
JavaScript
var assert = require('assert');
|
|
|
|
add_dependencies({
|
|
_: 'third/underscore/underscore.js',
|
|
util: 'js/util.js',
|
|
Dict: 'js/dict.js'
|
|
});
|
|
|
|
var activity = require('js/activity.js');
|
|
|
|
(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'
|
|
};
|
|
|
|
|
|
set_global('people_dict', new global.Dict.from({
|
|
'alice@zulip.com': 'Alice Smith',
|
|
'fred@zulip.com': 'Fred Flintstone',
|
|
'jill@zulip.com': 'Jill Hill'
|
|
}));
|
|
|
|
activity._sort_users(users, user_info);
|
|
|
|
assert.deepEqual(users, [
|
|
'fred@zulip.com',
|
|
'jill@zulip.com',
|
|
'alice@zulip.com'
|
|
]);
|
|
}());
|