zulip/zerver/tests/frontend/node/activity.js
Steve Howell d21cbac611 Clean up globals after each unit test.
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)
2013-08-21 18:18:58 -04:00

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 = ['[email protected]', '[email protected]', '[email protected]'];
var user_info = {
'[email protected]': 'inactive',
'[email protected]': 'active',
'[email protected]': 'active'
};
set_global('people_dict', new global.Dict.from({
'[email protected]': 'Alice Smith',
'[email protected]': 'Fred Flintstone',
'[email protected]': 'Jill Hill'
}));
activity._sort_users(users, user_info);
assert.deepEqual(users, [
'[email protected]',
'[email protected]',
'[email protected]'
]);
}());