From a2809dd361f214ff4ec67d39ba079524c3e72481 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Fri, 16 Apr 2021 15:44:46 +0000 Subject: [PATCH] node tests: Localize all_messages stub. --- frontend_tests/node_tests/recent_topics.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/frontend_tests/node_tests/recent_topics.js b/frontend_tests/node_tests/recent_topics.js index 0030d4b3f6..89d51f6777 100644 --- a/frontend_tests/node_tests/recent_topics.js +++ b/frontend_tests/node_tests/recent_topics.js @@ -37,13 +37,7 @@ const topic9 = "topic-9"; const topic10 = "topic-10"; mock_cjs("jquery", $); -const {all_messages_data} = mock_esm("../../static/js/all_messages_data", { - all_messages_data: { - all_messages() { - return messages; - }, - }, -}); + const ListWidget = mock_esm("../../static/js/list_widget", { modifier: noop, @@ -85,6 +79,9 @@ mock_esm("../../static/js/hash_util", { mock_esm("../../static/js/narrow", { set_narrow_title: noop, }); +mock_esm("../../static/js/message_list_data", { + MessageListData: class {}, +}); mock_esm("../../static/js/message_store", { get: (msg_id) => messages[msg_id - 1], }); @@ -163,6 +160,7 @@ set_global("localStorage", { }, }); +const {all_messages_data} = zrequire("all_messages_data"); const people = zrequire("people"); const rt = zrequire("recent_topics"); @@ -730,7 +728,9 @@ test("test_delete_messages", (override) => { rt.update_topics_of_deleted_message_ids([-1]); }); -test("test_topic_edit", () => { +test("test_topic_edit", (override) => { + override(all_messages_data, "all_messages", () => messages); + // NOTE: This test should always run in the end as it modified the messages data. rt.clear_for_tests(); stub_out_filter_buttons();