mirror of
https://github.com/zulip/zulip.git
synced 2026-06-12 21:00:58 +08:00
This commit was originally automatically generated using `tools/lint --only=eslint --fix`. It was then modified by tabbott to contain only changes to a set of files that are unlikely to result in significant merge conflicts with any open pull request, excluding about 20 files. His plan is to merge the remaining changes with more precise care, potentially involving merging parts of conflicting pull requests before running the `eslint --fix` operation. Signed-off-by: Anders Kaseorg <[email protected]>
81 lines
1.9 KiB
JavaScript
81 lines
1.9 KiB
JavaScript
set_global('blueslip', {});
|
|
global.blueslip.warn = function () {};
|
|
|
|
zrequire('util');
|
|
zrequire('stream_data');
|
|
zrequire('people');
|
|
zrequire('compose_fade');
|
|
|
|
const me = {
|
|
email: '[email protected]',
|
|
user_id: 30,
|
|
full_name: 'Me Myself',
|
|
};
|
|
|
|
const alice = {
|
|
email: '[email protected]',
|
|
user_id: 31,
|
|
full_name: 'Alice',
|
|
};
|
|
|
|
const bob = {
|
|
email: '[email protected]',
|
|
user_id: 32,
|
|
full_name: 'Bob',
|
|
};
|
|
|
|
people.add_in_realm(me);
|
|
people.initialize_current_user(me.user_id);
|
|
|
|
people.add_in_realm(alice);
|
|
people.add_in_realm(bob);
|
|
|
|
|
|
run_test('set_focused_recipient', () => {
|
|
const sub = {
|
|
stream_id: 101,
|
|
name: 'social',
|
|
subscribed: true,
|
|
can_access_subscribers: 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_message_recipient_stream':
|
|
return {
|
|
val: function () {
|
|
return 'social';
|
|
},
|
|
};
|
|
case '#stream_message_recipient_topic':
|
|
return {
|
|
val: function () {
|
|
return 'lunch';
|
|
},
|
|
};
|
|
}
|
|
};
|
|
|
|
compose_fade.set_focused_recipient('stream');
|
|
|
|
assert.equal(compose_fade.would_receive_message('[email protected]'), true);
|
|
assert.equal(compose_fade.would_receive_message('[email protected]'), true);
|
|
assert.equal(compose_fade.would_receive_message('[email protected]'), false);
|
|
assert.equal(compose_fade.would_receive_message('[email protected]'), true);
|
|
|
|
const good_msg = {
|
|
type: 'stream',
|
|
stream_id: 101,
|
|
subject: 'lunch',
|
|
};
|
|
const bad_msg = {
|
|
type: 'stream',
|
|
stream_id: 999,
|
|
subject: 'lunch',
|
|
};
|
|
assert(!compose_fade.should_fade_message(good_msg));
|
|
assert(compose_fade.should_fade_message(bad_msg));
|
|
});
|