2017-02-23 23:39:43 +01:00
|
|
|
set_global('$', function () {
|
|
|
|
});
|
|
|
|
|
2017-11-08 16:59:01 +01:00
|
|
|
zrequire('util');
|
|
|
|
zrequire('stream_data');
|
|
|
|
zrequire('people');
|
|
|
|
zrequire('compose_fade');
|
2017-02-23 23:39:43 +01:00
|
|
|
|
|
|
|
var me = {
|
|
|
|
email: 'me@example.com',
|
|
|
|
user_id: 30,
|
|
|
|
full_name: 'Me Myself',
|
|
|
|
};
|
|
|
|
|
|
|
|
var alice = {
|
|
|
|
email: 'alice@example.com',
|
|
|
|
user_id: 31,
|
|
|
|
full_name: 'Alice',
|
|
|
|
};
|
|
|
|
|
|
|
|
var bob = {
|
|
|
|
email: 'bob@example.com',
|
|
|
|
user_id: 32,
|
|
|
|
full_name: 'Bob',
|
|
|
|
};
|
|
|
|
|
|
|
|
people.add(me);
|
|
|
|
people.initialize_current_user(me.user_id);
|
|
|
|
|
|
|
|
people.add(alice);
|
|
|
|
people.add(bob);
|
|
|
|
|
|
|
|
|
|
|
|
(function test_set_focused_recipient() {
|
|
|
|
var sub = {
|
|
|
|
stream_id: 101,
|
|
|
|
name: 'social',
|
|
|
|
subscribed: true,
|
|
|
|
};
|
|
|
|
stream_data.add_sub('social', sub);
|
|
|
|
stream_data.set_subscribers(sub, [me.user_id, alice.user_id]);
|
|
|
|
|
|
|
|
global.$ = function (selector) {
|
|
|
|
switch (selector) {
|
|
|
|
case '#stream':
|
|
|
|
return {
|
|
|
|
val: function () {
|
|
|
|
return 'social';
|
|
|
|
},
|
|
|
|
};
|
|
|
|
case '#subject':
|
|
|
|
return {
|
|
|
|
val: function () {
|
|
|
|
return 'lunch';
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
compose_fade.set_focused_recipient('stream');
|
|
|
|
|
|
|
|
assert(compose_fade.would_receive_message('me@example.com'));
|
|
|
|
assert(compose_fade.would_receive_message('alice@example.com'));
|
|
|
|
assert(!compose_fade.would_receive_message('bob@example.com'));
|
2017-02-24 01:20:49 +01:00
|
|
|
|
|
|
|
var good_msg = {
|
|
|
|
type: 'stream',
|
2017-02-23 03:53:02 +01:00
|
|
|
stream_id: 101,
|
2017-02-24 01:20:49 +01:00
|
|
|
subject: 'lunch',
|
|
|
|
};
|
|
|
|
var bad_msg = {
|
|
|
|
type: 'stream',
|
2017-02-23 03:53:02 +01:00
|
|
|
stream_id: 999,
|
2017-02-24 01:20:49 +01:00
|
|
|
subject: 'lunch',
|
|
|
|
};
|
|
|
|
assert(!compose_fade.should_fade_message(good_msg));
|
|
|
|
assert(compose_fade.should_fade_message(bad_msg));
|
2017-02-23 23:39:43 +01:00
|
|
|
}());
|