From 09336c9e28fae26a3ddb583e75a8440e3d738d8a Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Fri, 3 Apr 2020 15:23:56 +0000 Subject: [PATCH] node test: Clean up ad hoc mocks for blueslip. --- frontend_tests/node_tests/compose_fade.js | 3 --- frontend_tests/node_tests/compose_ui.js | 5 ----- frontend_tests/node_tests/composebox_typeahead.js | 4 +--- frontend_tests/node_tests/drafts.js | 2 -- frontend_tests/node_tests/narrow_activate.js | 5 +---- frontend_tests/node_tests/presence.js | 13 ++++--------- frontend_tests/node_tests/settings_org.js | 4 +--- frontend_tests/node_tests/unread.js | 1 - 8 files changed, 7 insertions(+), 30 deletions(-) diff --git a/frontend_tests/node_tests/compose_fade.js b/frontend_tests/node_tests/compose_fade.js index fc55b2baa3..8e54d6f849 100644 --- a/frontend_tests/node_tests/compose_fade.js +++ b/frontend_tests/node_tests/compose_fade.js @@ -1,6 +1,3 @@ -set_global('blueslip', {}); -global.blueslip.warn = function () {}; - zrequire('stream_data'); zrequire('people'); zrequire('compose_fade'); diff --git a/frontend_tests/node_tests/compose_ui.js b/frontend_tests/node_tests/compose_ui.js index cd0fa5360d..dd60764034 100644 --- a/frontend_tests/node_tests/compose_ui.js +++ b/frontend_tests/node_tests/compose_ui.js @@ -7,7 +7,6 @@ set_global('document', { }); set_global('$', global.make_zjquery()); -set_global('blueslip', {}); const alice = { email: 'alice@zulip.com', @@ -23,8 +22,6 @@ const bob = { people.add(alice); people.add(bob); -const noop = function () {}; - function make_textbox(s) { // Simulate a jQuery textbox for testing purposes. const widget = {}; @@ -75,8 +72,6 @@ function make_textbox(s) { } run_test('insert_syntax_and_focus', () => { - blueslip.error = noop; - blueslip.log = noop; $('#compose-textarea').val("xyz "); $('#compose-textarea').caret = function (syntax) { if (syntax !== undefined) { diff --git a/frontend_tests/node_tests/composebox_typeahead.js b/frontend_tests/node_tests/composebox_typeahead.js index 4e5b43ef08..4424814c35 100644 --- a/frontend_tests/node_tests/composebox_typeahead.js +++ b/frontend_tests/node_tests/composebox_typeahead.js @@ -31,9 +31,6 @@ set_global('message_store', { const ct = composebox_typeahead; const noop = function () {}; -set_global('blueslip', {}); -blueslip.warn = noop; - // Use a slightly larger value than what's user-facing // to facilitate testing different combinations of // broadcast-mentions/persons/groups. @@ -145,6 +142,7 @@ const sweden_stream = { description: 'Cold, mountains and home decor.', stream_id: 1, subscribed: true, + can_access_subscribers: true, }; const denmark_stream = { name: 'Denmark', diff --git a/frontend_tests/node_tests/drafts.js b/frontend_tests/node_tests/drafts.js index 283fb82e36..1665c926b9 100644 --- a/frontend_tests/node_tests/drafts.js +++ b/frontend_tests/node_tests/drafts.js @@ -32,7 +32,6 @@ set_global('stream_data', { return '#FFFFFF'; }, }); -set_global('blueslip', {}); set_global('people', { // Mocking get_by_email function, here we are // just returning string before `@` in email @@ -300,7 +299,6 @@ run_test('format_drafts', () => { }, ]; - blueslip.error = noop; $('#drafts_table').append = noop; const draft_model = drafts.draft_model; diff --git a/frontend_tests/node_tests/narrow_activate.js b/frontend_tests/node_tests/narrow_activate.js index c1b9d58d76..201c0cd266 100644 --- a/frontend_tests/node_tests/narrow_activate.js +++ b/frontend_tests/node_tests/narrow_activate.js @@ -1,3 +1,4 @@ +set_global('blueslip', global.make_zblueslip()); const util = zrequire('util'); set_global('$', global.make_zjquery()); @@ -9,7 +10,6 @@ zrequire('unread'); zrequire('narrow'); zrequire('search_pill'); -set_global('blueslip', {}); set_global('channel', {}); set_global('compose', {}); 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 // seconds. @@ -86,8 +85,6 @@ function test_helper() { stub('compose', 'update_closed_compose_buttons_for_private'); stub('notifications', 'hide_history_limit_message'); - blueslip.debug = noop; - return { clear: () => { events = []; diff --git a/frontend_tests/node_tests/presence.js b/frontend_tests/node_tests/presence.js index 19609d50cf..c1c02f0d07 100644 --- a/frontend_tests/node_tests/presence.js +++ b/frontend_tests/node_tests/presence.js @@ -1,10 +1,10 @@ +set_global('blueslip', global.make_zblueslip()); zrequire('people'); zrequire('presence'); const return_false = function () { return false; }; set_global('server_events', {}); -set_global('blueslip', {}); set_global('reload_state', { is_in_progress: return_false, }); @@ -122,17 +122,12 @@ run_test('status_from_timestamp', () => { timestamp: base_time + OFFLINE_THRESHOLD_SECS / 2, pushable: true, }; - let called = false; - blueslip.error = function (msg, more_info, stack) { - assert.equal(msg, 'Unexpected status'); - assert.deepEqual(more_info.presence_object, info.random_client); - assert.equal(stack, undefined); - called = true; - }; + + blueslip.expect('error', 'Unexpected status'); status = status_from_timestamp( base_time + OFFLINE_THRESHOLD_SECS - 1, info); + blueslip.reset(); assert.equal(status.status, "active"); // website - assert(called); }); run_test('set_presence_info', () => { diff --git a/frontend_tests/node_tests/settings_org.js b/frontend_tests/node_tests/settings_org.js index 0a5d7e6962..2b5fafde2d 100644 --- a/frontend_tests/node_tests/settings_org.js +++ b/frontend_tests/node_tests/settings_org.js @@ -476,9 +476,7 @@ function test_sync_realm_settings() { property_elem.attr('id', 'id_realm_invalid_settings_property'); property_elem.length = 1; - blueslip.error = error_string => { - assert.equal(error_string, 'Element refers to unknown property realm_invalid_settings_property'); - }; + blueslip.expect('error', 'Element refers to unknown property realm_invalid_settings_property'); settings_org.sync_realm_settings('invalid_settings_property'); } diff --git a/frontend_tests/node_tests/unread.js b/frontend_tests/node_tests/unread.js index f1f0d3e360..cd21374e38 100644 --- a/frontend_tests/node_tests/unread.js +++ b/frontend_tests/node_tests/unread.js @@ -11,7 +11,6 @@ zrequire('settings_notifications'); const FoldDict = zrequire('fold_dict').FoldDict; -set_global('blueslip', {}); set_global('narrow_state', {}); set_global('current_msg_list', {}); set_global('home_msg_list', {});