mirror of https://github.com/zulip/zulip.git
node tests: Clear data for pm_list tests.
This commit is contained in:
parent
67a5fe95dc
commit
bbf529f2a5
|
@ -53,7 +53,15 @@ people.add_active_user(me);
|
|||
people.add_active_user(bot_test);
|
||||
people.initialize_current_user(me.user_id);
|
||||
|
||||
run_test("close", () => {
|
||||
function test(label, f) {
|
||||
run_test(label, (override) => {
|
||||
pm_conversations.recent.clear_for_testing();
|
||||
pm_list.clear_for_testing();
|
||||
f(override);
|
||||
});
|
||||
}
|
||||
|
||||
test("close", () => {
|
||||
let collapsed;
|
||||
$("#private-container").empty = () => {
|
||||
collapsed = true;
|
||||
|
@ -62,7 +70,7 @@ run_test("close", () => {
|
|||
assert(collapsed);
|
||||
});
|
||||
|
||||
run_test("build_private_messages_list", (override) => {
|
||||
test("build_private_messages_list", (override) => {
|
||||
const timestamp = 0;
|
||||
pm_conversations.recent.insert([101, 102], timestamp);
|
||||
|
||||
|
@ -104,8 +112,9 @@ run_test("build_private_messages_list", (override) => {
|
|||
assert.deepEqual(pm_data, expected_data);
|
||||
});
|
||||
|
||||
run_test("build_private_messages_list_bot", (override) => {
|
||||
test("build_private_messages_list_bot", (override) => {
|
||||
const timestamp = 0;
|
||||
pm_conversations.recent.insert([101, 102], timestamp);
|
||||
pm_conversations.recent.insert([314], timestamp);
|
||||
|
||||
override(unread, "num_unread_for_person", () => 1);
|
||||
|
@ -146,7 +155,7 @@ run_test("build_private_messages_list_bot", (override) => {
|
|||
assert.deepEqual(pm_data, expected_data);
|
||||
});
|
||||
|
||||
run_test("update_dom_with_unread_counts", (override) => {
|
||||
test("update_dom_with_unread_counts", (override) => {
|
||||
let counts;
|
||||
let toggle_button_set;
|
||||
let expected_unread_count;
|
||||
|
@ -185,7 +194,7 @@ run_test("update_dom_with_unread_counts", (override) => {
|
|||
assert(toggle_button_set);
|
||||
});
|
||||
|
||||
run_test("get_active_user_ids_string", (override) => {
|
||||
test("get_active_user_ids_string", (override) => {
|
||||
let active_filter;
|
||||
|
||||
override(narrow_state, "filter", () => active_filter);
|
||||
|
@ -217,7 +226,7 @@ function private_filter() {
|
|||
};
|
||||
}
|
||||
|
||||
run_test("is_all_privates", (override) => {
|
||||
test("is_all_privates", (override) => {
|
||||
let filter;
|
||||
override(narrow_state, "filter", () => filter);
|
||||
|
||||
|
@ -228,7 +237,7 @@ run_test("is_all_privates", (override) => {
|
|||
assert.equal(pm_list.is_all_privates(), true);
|
||||
});
|
||||
|
||||
run_test("expand", (override) => {
|
||||
test("expand", (override) => {
|
||||
override(narrow_state, "filter", private_filter);
|
||||
override(narrow_state, "active", () => true);
|
||||
override(pm_list, "_build_private_messages_list", () => "PM_LIST_CONTENTS");
|
||||
|
@ -244,10 +253,11 @@ run_test("expand", (override) => {
|
|||
assert($(".top_left_private_messages").hasClass("active-filter"));
|
||||
});
|
||||
|
||||
run_test("update_private_messages", (override) => {
|
||||
test("update_private_messages", (override) => {
|
||||
let html_updated;
|
||||
let container_found;
|
||||
|
||||
override(narrow_state, "filter", private_filter);
|
||||
override(narrow_state, "active", () => true);
|
||||
override(pm_list, "_build_private_messages_list", () => "PM_LIST_CONTENTS");
|
||||
|
||||
|
@ -264,12 +274,13 @@ run_test("update_private_messages", (override) => {
|
|||
find();
|
||||
});
|
||||
|
||||
pm_list.expand();
|
||||
pm_list.update_private_messages();
|
||||
assert(html_updated);
|
||||
assert(container_found);
|
||||
});
|
||||
|
||||
run_test("ensure coverage", (override) => {
|
||||
test("ensure coverage", (override) => {
|
||||
// These aren't rigorous; they just cover cases
|
||||
// where functions early exit.
|
||||
override(narrow_state, "active", () => false);
|
||||
|
|
|
@ -13,6 +13,11 @@ import * as vdom from "./vdom";
|
|||
let prior_dom;
|
||||
let private_messages_open = false;
|
||||
|
||||
export function clear_for_testing() {
|
||||
prior_dom = undefined;
|
||||
private_messages_open = false;
|
||||
}
|
||||
|
||||
// This module manages the "Private messages" section in the upper
|
||||
// left corner of the app. This was split out from stream_list.js.
|
||||
|
||||
|
|
Loading…
Reference in New Issue