node test: Clean up ad hoc mocks for blueslip.

This commit is contained in:
Steve Howell 2020-04-03 15:23:56 +00:00 committed by showell
parent df84c52a7f
commit 09336c9e28
8 changed files with 7 additions and 30 deletions

View File

@ -1,6 +1,3 @@
set_global('blueslip', {});
global.blueslip.warn = function () {};
zrequire('stream_data'); zrequire('stream_data');
zrequire('people'); zrequire('people');
zrequire('compose_fade'); zrequire('compose_fade');

View File

@ -7,7 +7,6 @@ set_global('document', {
}); });
set_global('$', global.make_zjquery()); set_global('$', global.make_zjquery());
set_global('blueslip', {});
const alice = { const alice = {
email: 'alice@zulip.com', email: 'alice@zulip.com',
@ -23,8 +22,6 @@ const bob = {
people.add(alice); people.add(alice);
people.add(bob); people.add(bob);
const noop = function () {};
function make_textbox(s) { function make_textbox(s) {
// Simulate a jQuery textbox for testing purposes. // Simulate a jQuery textbox for testing purposes.
const widget = {}; const widget = {};
@ -75,8 +72,6 @@ function make_textbox(s) {
} }
run_test('insert_syntax_and_focus', () => { run_test('insert_syntax_and_focus', () => {
blueslip.error = noop;
blueslip.log = noop;
$('#compose-textarea').val("xyz "); $('#compose-textarea').val("xyz ");
$('#compose-textarea').caret = function (syntax) { $('#compose-textarea').caret = function (syntax) {
if (syntax !== undefined) { if (syntax !== undefined) {

View File

@ -31,9 +31,6 @@ set_global('message_store', {
const ct = composebox_typeahead; const ct = composebox_typeahead;
const noop = function () {}; const noop = function () {};
set_global('blueslip', {});
blueslip.warn = noop;
// Use a slightly larger value than what's user-facing // Use a slightly larger value than what's user-facing
// to facilitate testing different combinations of // to facilitate testing different combinations of
// broadcast-mentions/persons/groups. // broadcast-mentions/persons/groups.
@ -145,6 +142,7 @@ const sweden_stream = {
description: 'Cold, mountains and home decor.', description: 'Cold, mountains and home decor.',
stream_id: 1, stream_id: 1,
subscribed: true, subscribed: true,
can_access_subscribers: true,
}; };
const denmark_stream = { const denmark_stream = {
name: 'Denmark', name: 'Denmark',

View File

@ -32,7 +32,6 @@ set_global('stream_data', {
return '#FFFFFF'; return '#FFFFFF';
}, },
}); });
set_global('blueslip', {});
set_global('people', { set_global('people', {
// Mocking get_by_email function, here we are // Mocking get_by_email function, here we are
// just returning string before `@` in email // just returning string before `@` in email
@ -300,7 +299,6 @@ run_test('format_drafts', () => {
}, },
]; ];
blueslip.error = noop;
$('#drafts_table').append = noop; $('#drafts_table').append = noop;
const draft_model = drafts.draft_model; const draft_model = drafts.draft_model;

View File

@ -1,3 +1,4 @@
set_global('blueslip', global.make_zblueslip());
const util = zrequire('util'); const util = zrequire('util');
set_global('$', global.make_zjquery()); set_global('$', global.make_zjquery());
@ -9,7 +10,6 @@ zrequire('unread');
zrequire('narrow'); zrequire('narrow');
zrequire('search_pill'); zrequire('search_pill');
set_global('blueslip', {});
set_global('channel', {}); set_global('channel', {});
set_global('compose', {}); set_global('compose', {});
set_global('compose_actions', {}); set_global('compose_actions', {});
@ -38,7 +38,6 @@ set_global('search_pill_widget', {
}, },
}); });
const noop = () => {};
// //
// We have strange hacks in narrow.activate to sleep 0 // We have strange hacks in narrow.activate to sleep 0
// seconds. // seconds.
@ -86,8 +85,6 @@ function test_helper() {
stub('compose', 'update_closed_compose_buttons_for_private'); stub('compose', 'update_closed_compose_buttons_for_private');
stub('notifications', 'hide_history_limit_message'); stub('notifications', 'hide_history_limit_message');
blueslip.debug = noop;
return { return {
clear: () => { clear: () => {
events = []; events = [];

View File

@ -1,10 +1,10 @@
set_global('blueslip', global.make_zblueslip());
zrequire('people'); zrequire('people');
zrequire('presence'); zrequire('presence');
const return_false = function () { return false; }; const return_false = function () { return false; };
set_global('server_events', {}); set_global('server_events', {});
set_global('blueslip', {});
set_global('reload_state', { set_global('reload_state', {
is_in_progress: return_false, is_in_progress: return_false,
}); });
@ -122,17 +122,12 @@ run_test('status_from_timestamp', () => {
timestamp: base_time + OFFLINE_THRESHOLD_SECS / 2, timestamp: base_time + OFFLINE_THRESHOLD_SECS / 2,
pushable: true, pushable: true,
}; };
let called = false;
blueslip.error = function (msg, more_info, stack) { blueslip.expect('error', 'Unexpected status');
assert.equal(msg, 'Unexpected status');
assert.deepEqual(more_info.presence_object, info.random_client);
assert.equal(stack, undefined);
called = true;
};
status = status_from_timestamp( status = status_from_timestamp(
base_time + OFFLINE_THRESHOLD_SECS - 1, info); base_time + OFFLINE_THRESHOLD_SECS - 1, info);
blueslip.reset();
assert.equal(status.status, "active"); // website assert.equal(status.status, "active"); // website
assert(called);
}); });
run_test('set_presence_info', () => { run_test('set_presence_info', () => {

View File

@ -476,9 +476,7 @@ function test_sync_realm_settings() {
property_elem.attr('id', 'id_realm_invalid_settings_property'); property_elem.attr('id', 'id_realm_invalid_settings_property');
property_elem.length = 1; property_elem.length = 1;
blueslip.error = error_string => { blueslip.expect('error', 'Element refers to unknown property realm_invalid_settings_property');
assert.equal(error_string, 'Element refers to unknown property realm_invalid_settings_property');
};
settings_org.sync_realm_settings('invalid_settings_property'); settings_org.sync_realm_settings('invalid_settings_property');
} }

View File

@ -11,7 +11,6 @@ zrequire('settings_notifications');
const FoldDict = zrequire('fold_dict').FoldDict; const FoldDict = zrequire('fold_dict').FoldDict;
set_global('blueslip', {});
set_global('narrow_state', {}); set_global('narrow_state', {});
set_global('current_msg_list', {}); set_global('current_msg_list', {});
set_global('home_msg_list', {}); set_global('home_msg_list', {});