From ece986bd10b03e3a28ce8624dd7d8f0db3b58a55 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Mon, 15 Mar 2021 16:24:45 +0000 Subject: [PATCH] node tests: Clear data for sort_recipients. --- frontend_tests/node_tests/typeahead_helper.js | 15 +++++++++++++-- static/js/pm_conversations.js | 5 +++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/frontend_tests/node_tests/typeahead_helper.js b/frontend_tests/node_tests/typeahead_helper.js index eec2f1d511..f86054d206 100644 --- a/frontend_tests/node_tests/typeahead_helper.js +++ b/frontend_tests/node_tests/typeahead_helper.js @@ -299,6 +299,19 @@ function get_typeahead_result(query, current_stream, current_topic) { } run_test("sort_recipients", () => { + pm_conversations.clear_for_testing(); + recent_senders.clear_for_testing(); + peer_data.clear_for_testing(); + a_bot.pm_recipient_count = 0; + a_user.pm_recipient_count = 0; + b_user_1.pm_recipient_count = 0; + b_user_2.pm_recipient_count = 0; + b_user_3.pm_recipient_count = 0; + b_bot.pm_recipient_count = 0; + + const dev_sub = stream_data.get_sub("Dev"); + const linux_sub = stream_data.get_sub("Linux"); + // Typeahead for recipientbox [query, "", undefined] assert.deepEqual(get_typeahead_result("b", ""), [ "b_user_1@zulip.net", @@ -328,8 +341,6 @@ run_test("sort_recipients", () => { peer_data.add_subscriber(1, people.get_user_id(subscriber_email_2)); peer_data.add_subscriber(1, people.get_user_id(subscriber_email_3)); - const dev_sub = stream_data.get_sub("Dev"); - const linux_sub = stream_data.get_sub("Linux"); stream_data.update_calculated_fields(dev_sub); stream_data.update_calculated_fields(linux_sub); diff --git a/static/js/pm_conversations.js b/static/js/pm_conversations.js index ccf99ee3d4..03e7450377 100644 --- a/static/js/pm_conversations.js +++ b/static/js/pm_conversations.js @@ -82,3 +82,8 @@ class RecentPrivateMessages { } export const recent = new RecentPrivateMessages(); + +export function clear_for_testing() { + recent.clear_for_testing(); + partners.clear(); +}