node tests: Clean pm_conversations more simply.

This commit is contained in:
Steve Howell
2021-03-18 14:20:04 +00:00
committed by Steve Howell
parent b2be16c4d0
commit 728905d4bc
3 changed files with 4 additions and 10 deletions

View File

@@ -9,7 +9,7 @@ const people = zrequire("people");
const pmc = zrequire("pm_conversations");
function initialize_recents(params) {
pmc.recent.clear_for_testing();
pmc.clear_for_testing();
pmc.recent.initialize(params);
}

View File

@@ -56,7 +56,7 @@ people.initialize_current_user(me.user_id);
function test(label, f) {
run_test(label, (override) => {
pm_conversations.recent.clear_for_testing();
pm_conversations.clear_for_testing();
pm_list.clear_for_testing();
f(override);
});

View File

@@ -18,12 +18,6 @@ class RecentPrivateMessages {
recent_message_ids = new FoldDict(); // key is user_ids_string
recent_private_messages = [];
clear_for_testing() {
// Because we only export the singleton, we need this for tests.
this.recent_message_ids.clear();
this.recent_private_messages.length = 0;
}
insert(user_ids, message_id) {
if (user_ids.length === 0) {
// The server sends [] for self-PMs.
@@ -81,9 +75,9 @@ class RecentPrivateMessages {
}
}
export const recent = new RecentPrivateMessages();
export let recent = new RecentPrivateMessages();
export function clear_for_testing() {
recent.clear_for_testing();
recent = new RecentPrivateMessages();
partners.clear();
}