2016-11-18 19:08:41 +01:00
|
|
|
global.stub_out_jquery();
|
|
|
|
|
|
|
|
add_dependencies({
|
|
|
|
people: 'js/people.js',
|
2016-12-03 23:17:57 +01:00
|
|
|
util: 'js/util.js',
|
2016-11-18 19:08:41 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
var noop = function () {};
|
|
|
|
var people = global.people;
|
|
|
|
|
|
|
|
set_global('alert_words', {
|
2016-12-03 23:17:57 +01:00
|
|
|
process_message: noop,
|
2016-11-18 19:08:41 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
var me = {
|
|
|
|
email: 'me@example.com',
|
|
|
|
user_id: 101,
|
2016-12-03 23:17:57 +01:00
|
|
|
full_name: 'Me Myself',
|
2016-11-18 19:08:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
var alice = {
|
|
|
|
email: 'alice@example.com',
|
|
|
|
user_id: 102,
|
2016-12-03 23:17:57 +01:00
|
|
|
full_name: 'Alice',
|
2016-11-18 19:08:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
var bob = {
|
|
|
|
email: 'bob@example.com',
|
|
|
|
user_id: 103,
|
2016-12-03 23:17:57 +01:00
|
|
|
full_name: 'Bob',
|
2016-11-18 19:08:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
var cindy = {
|
|
|
|
email: 'cindy@example.com',
|
|
|
|
user_id: 104,
|
2016-12-03 23:17:57 +01:00
|
|
|
full_name: 'Cindy',
|
2016-11-18 19:08:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
people.add_in_realm(me);
|
|
|
|
people.add_in_realm(alice);
|
|
|
|
people.add_in_realm(bob);
|
|
|
|
people.add_in_realm(cindy);
|
|
|
|
|
2017-01-20 23:16:28 +01:00
|
|
|
global.people.initialize_current_user(me.user_id);
|
2017-01-19 23:04:52 +01:00
|
|
|
|
2016-11-18 19:08:41 +01:00
|
|
|
global.util.execute_early = noop;
|
|
|
|
|
|
|
|
var message_store = require('js/message_store.js');
|
|
|
|
|
2017-04-13 20:41:53 +02:00
|
|
|
(function test_insert_recent_private_message() {
|
|
|
|
message_store.insert_recent_private_message('1', 1001);
|
|
|
|
message_store.insert_recent_private_message('2', 2001);
|
|
|
|
message_store.insert_recent_private_message('1', 3001);
|
|
|
|
|
|
|
|
assert.deepEqual(message_store.recent_private_messages, [
|
|
|
|
{user_ids_string: '1', timestamp: 3001},
|
|
|
|
{user_ids_string: '2', timestamp: 2001},
|
|
|
|
]);
|
|
|
|
}());
|
|
|
|
|
2016-11-18 19:08:41 +01:00
|
|
|
(function test_add_message_metadata() {
|
|
|
|
var message = {
|
|
|
|
sender_email: 'me@example.com',
|
2017-01-24 23:10:01 +01:00
|
|
|
sender_id: me.user_id,
|
2016-11-18 19:08:41 +01:00
|
|
|
type: 'private',
|
|
|
|
display_recipient: [me, bob, cindy],
|
2016-12-03 23:17:57 +01:00
|
|
|
flags: ['has_alert_word'],
|
2016-11-18 19:08:41 +01:00
|
|
|
};
|
2017-03-19 18:19:48 +01:00
|
|
|
message_store.add_message_metadata(message);
|
2016-11-18 19:08:41 +01:00
|
|
|
|
|
|
|
assert.equal(message.is_private, true);
|
|
|
|
assert.equal(message.reply_to, 'bob@example.com,cindy@example.com');
|
2017-02-25 00:19:02 +01:00
|
|
|
assert.equal(message.to_user_ids, '103,104');
|
2016-11-18 19:08:41 +01:00
|
|
|
assert.equal(message.display_reply_to, 'Bob, Cindy');
|
|
|
|
assert.equal(message.alerted, true);
|
|
|
|
assert.equal(message.is_me_message, false);
|
|
|
|
}());
|