node tests: Use {override} in run_test.

This commit is contained in:
Steve Howell 2021-06-16 12:38:37 +00:00 committed by Steve Howell
parent 1acee9f516
commit 9e657dd795
91 changed files with 415 additions and 413 deletions

View File

@ -98,7 +98,7 @@ function clear_buddy_list() {
let presence_info;
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
// Simulate a small window by having the
// fill_screen_with_content render the entire
// list in one pass. We will do more refined
@ -126,7 +126,7 @@ function test(label, f) {
activity.clear_for_testing();
activity.set_cursor_and_filter();
f(override);
f({override});
});
}
@ -205,7 +205,7 @@ test("huddle_data.process_loaded_messages", () => {
assert.deepEqual(huddle_data.get_huddles(), [user_ids_string2, user_ids_string1]);
});
test("presence_list_full_update", (override) => {
test("presence_list_full_update", ({override}) => {
override(padded_widget, "update_padding", () => {});
$(".user-list-filter").trigger("focus");
@ -262,7 +262,7 @@ test("PM_update_dom_counts", () => {
assert.equal(count.text(), "");
});
test("handlers", (override) => {
test("handlers", ({override}) => {
let filter_key_handlers;
override(keydown_util, "handle", (opts) => {
@ -364,7 +364,7 @@ test("handlers", (override) => {
})();
});
test("first/prev/next", (override) => {
test("first/prev/next", ({override}) => {
override(padded_widget, "update_padding", () => {});
assert.equal(buddy_list.first_key(), undefined);
@ -384,7 +384,7 @@ test("first/prev/next", (override) => {
assert.equal(buddy_list.next_key(fred.user_id), undefined);
});
test("insert_one_user_into_empty_list", (override) => {
test("insert_one_user_into_empty_list", ({override}) => {
override(padded_widget, "update_padding", () => {});
let appended_html;
@ -397,7 +397,7 @@ test("insert_one_user_into_empty_list", (override) => {
assert.ok(appended_html.indexOf("user_circle_green") > 0);
});
test("insert_alice_then_fred", (override) => {
test("insert_alice_then_fred", ({override}) => {
let appended_html;
override(buddy_list.container, "append", (html) => {
appended_html = html;
@ -413,7 +413,7 @@ test("insert_alice_then_fred", (override) => {
assert.ok(appended_html.indexOf("user_circle_green") > 0);
});
test("insert_fred_then_alice_then_rename", (override) => {
test("insert_fred_then_alice_then_rename", ({override}) => {
let appended_html;
override(buddy_list.container, "append", (html) => {
appended_html = html;
@ -491,7 +491,7 @@ test("redraw_muted_user", () => {
assert.equal(appended_html, undefined);
});
test("update_presence_info", (override) => {
test("update_presence_info", ({override}) => {
override(pm_list, "update_private_messages", () => {});
page_params.realm_presence_disabled = false;
@ -527,7 +527,7 @@ test("update_presence_info", (override) => {
assert.deepEqual(presence.presence_info.get(alice.user_id), expected);
});
test("initialize", (override) => {
test("initialize", ({override}) => {
override(padded_widget, "update_padding", () => {});
override(pm_list, "update_private_messages", () => {});
override(watchdog, "check_for_unsuspend", () => {});
@ -592,7 +592,7 @@ test("initialize", (override) => {
clear();
});
test("away_status", (override) => {
test("away_status", ({override}) => {
override(pm_list, "update_private_messages", () => {});
override(buddy_list, "insert_or_move", () => {});
@ -603,7 +603,7 @@ test("away_status", (override) => {
assert.ok(!user_status.is_away(alice.user_id));
});
test("electron_bridge", (override) => {
test("electron_bridge", ({override}) => {
override(activity, "send_presence_to_server", () => {});
function with_bridge_idle(bridge_idle, f) {

View File

@ -19,7 +19,7 @@ alert_words.initialize({
alert_words: ["foo", "bar"],
});
run_test("render_alert_words_ui", (override) => {
run_test("render_alert_words_ui", ({override}) => {
const word_list = $("#alert_words_list");
const appended = [];
word_list.append = (rendered) => {
@ -42,7 +42,7 @@ run_test("render_alert_words_ui", (override) => {
assert.ok(new_alert_word.is_focused());
});
run_test("add_alert_word", (override) => {
run_test("add_alert_word", ({override}) => {
override(alert_words_ui, "render_alert_words_ui", () => {}); // we've already tested this above
alert_words_ui.set_up_alert_words();
@ -97,7 +97,7 @@ run_test("add_alert_word", (override) => {
assert.ok(alert_word_status.visible());
});
run_test("add_alert_word_keypress", (override) => {
run_test("add_alert_word_keypress", ({override}) => {
override(alert_words_ui, "render_alert_words_ui", () => {});
alert_words_ui.set_up_alert_words();
@ -123,7 +123,7 @@ run_test("add_alert_word_keypress", (override) => {
assert.ok(called);
});
run_test("remove_alert_word", (override) => {
run_test("remove_alert_word", ({override}) => {
override(alert_words_ui, "render_alert_words_ui", () => {});
alert_words_ui.set_up_alert_words();
@ -170,7 +170,7 @@ run_test("remove_alert_word", (override) => {
assert.ok(alert_word_status.visible());
});
run_test("close_status_message", (override) => {
run_test("close_status_message", ({override}) => {
override(alert_words_ui, "render_alert_words_ui", () => {});
alert_words_ui.set_up_alert_words();

View File

@ -24,7 +24,7 @@ const helpers = mock_esm("../../static/js/billing/helpers", {
const billing = zrequire("billing/billing");
run_test("initialize", (override) => {
run_test("initialize", ({override}) => {
let token_func;
let set_tab_called = false;

View File

@ -30,7 +30,7 @@ const location = set_global("location", {
const helpers = zrequire("billing/helpers");
run_test("create_ajax_request", (override) => {
run_test("create_ajax_request", ({override}) => {
const form_loading_indicator = "#autopay_loading_indicator";
const form_input_section = "#autopay-input-section";
const form_success = "#autopay-success";

View File

@ -34,14 +34,14 @@ const bot_data_params = {
};
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
people.add_active_user(me);
people.initialize_current_user(me.user_id);
bot_data.initialize(bot_data_params);
// Our startup logic should have added Bot 0 from page_params.
assert.equal(bot_data.get(42).full_name, "Bot 0");
assert.equal(bot_data.get(314).full_name, "Outgoing webhook");
f(override);
f({override});
});
}

View File

@ -14,10 +14,10 @@ const location = set_global("location", {
});
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
location.hash = "bogus";
browser_history.clear_for_testing();
f(override);
f({override});
});
}
@ -51,7 +51,7 @@ test("error for bad hashes", () => {
browser_history.update(hash);
});
test("update internal hash if required", (override) => {
test("update internal hash if required", ({override}) => {
const hash = "#test/hash";
const stub = make_stub();
override(browser_history, "update", stub.f);

View File

@ -96,7 +96,7 @@ function add_canned_users() {
}
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
compose_fade_helper.clear_focused_recipient();
stream_data.clear_subscriptions();
peer_data.clear_for_testing();
@ -106,7 +106,7 @@ function test(label, f) {
people.add_active_user(me);
people.initialize_current_user(me.user_id);
muting.set_muted_users([]);
f(override);
f({override});
});
}
@ -498,7 +498,7 @@ test("level", () => {
assert.equal(buddy_data.level(selma.user_id), 3);
});
test("user_last_seen_time_status", (override) => {
test("user_last_seen_time_status", ({override}) => {
set_presence(selma.user_id, "active");
set_presence(me.user_id, "active");
@ -577,7 +577,7 @@ test("get_items_for_users", () => {
]);
});
test("error handling", (override) => {
test("error handling", ({override}) => {
override(presence, "get_user_ids", () => [42]);
blueslip.expect("error", "Unknown user_id in get_by_user_id: 42");
blueslip.expect("warn", "Got user_id in presence but not people: 42");

View File

@ -55,7 +55,7 @@ run_test("get_items", () => {
assert.deepEqual(items, [alice_li]);
});
run_test("basics", (override) => {
run_test("basics", ({override}) => {
const buddy_list = new BuddyList();
init_simulated_scrolling();
@ -100,7 +100,7 @@ run_test("basics", (override) => {
assert.equal(li, alice_li);
});
run_test("big_list", (override) => {
run_test("big_list", ({override}) => {
const buddy_list = new BuddyList();
const elem = init_simulated_scrolling();
@ -136,7 +136,7 @@ run_test("big_list", (override) => {
assert.equal(chunks_inserted, 6);
});
run_test("force_render", (override) => {
run_test("force_render", ({override}) => {
const buddy_list = new BuddyList();
buddy_list.render_count = 50;
@ -158,7 +158,7 @@ run_test("force_render", (override) => {
});
});
run_test("find_li w/force_render", (override) => {
run_test("find_li w/force_render", ({override}) => {
const buddy_list = new BuddyList();
// If we call find_li w/force_render set, and the
@ -196,7 +196,7 @@ run_test("find_li w/force_render", (override) => {
assert.ok(shown);
});
run_test("find_li w/bad key", (override) => {
run_test("find_li w/bad key", ({override}) => {
const buddy_list = new BuddyList();
override(buddy_list, "get_li_from_key", () => ({length: 0}));
@ -208,7 +208,7 @@ run_test("find_li w/bad key", (override) => {
assert.deepEqual(undefined_li, []);
});
run_test("scrolling", (override) => {
run_test("scrolling", ({override}) => {
const buddy_list = new BuddyList();
init_simulated_scrolling();

View File

@ -47,9 +47,9 @@ function test_with_mock_ajax(test_params) {
}
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
reload_state.clear_for_testing();
f(override);
f({override});
});
}

View File

@ -38,7 +38,7 @@ run_test("phrase_match", () => {
assert.ok(!common.phrase_match("tes", "hostess"));
});
run_test("copy_data_attribute_value", (override) => {
run_test("copy_data_attribute_value", ({override}) => {
const admin_emails_val = "iago@zulip.com";
const input = $.create("input");
@ -81,7 +81,7 @@ run_test("copy_data_attribute_value", (override) => {
assert.ok(faded_out);
});
run_test("adjust_mac_shortcuts non-mac", (override) => {
run_test("adjust_mac_shortcuts non-mac", ({override}) => {
override(common, "has_mac_keyboard", () => false);
// The adjust_mac_shortcuts has a really simple guard
@ -90,7 +90,7 @@ run_test("adjust_mac_shortcuts non-mac", (override) => {
common.adjust_mac_shortcuts("selector-that-does-not-exist");
});
run_test("adjust_mac_shortcuts mac", (override) => {
run_test("adjust_mac_shortcuts mac", ({override}) => {
const keys_to_test_mac = new Map([
["Backspace", "Delete"],
["Enter", "Return"],

View File

@ -109,7 +109,7 @@ function test_ui(label, f) {
run_test(label, f);
}
function initialize_handlers(override) {
function initialize_handlers({override}) {
override(compose, "compute_show_video_chat_button", () => false);
override(compose, "render_compose_box", () => {});
override(upload, "setup_upload", () => undefined);
@ -189,7 +189,7 @@ test_ui("right-to-left", () => {
assert.equal(textarea.hasClass("rtl"), false);
});
test_ui("markdown_shortcuts", (override) => {
test_ui("markdown_shortcuts", ({override}) => {
let queryCommandEnabled = true;
const event = {
key: "b",
@ -351,7 +351,7 @@ test_ui("markdown_shortcuts", (override) => {
navigator.userAgent = "";
});
test_ui("send_message_success", (override) => {
test_ui("send_message_success", ({override}) => {
override(drafts, "delete_active_draft", () => {});
$("#compose-textarea").val("foobarfoobar");
@ -378,7 +378,7 @@ test_ui("send_message_success", (override) => {
assert.ok(reify_message_id_checked);
});
test_ui("send_message", (override) => {
test_ui("send_message", ({override}) => {
MockDate.set(new Date(fake_now * 1000));
override(drafts, "delete_active_draft", () => {});
@ -536,7 +536,7 @@ test_ui("send_message", (override) => {
})();
});
test_ui("enter_with_preview_open", (override) => {
test_ui("enter_with_preview_open", ({override}) => {
override(notifications, "clear_compose_notifications", () => {});
override(reminder, "is_deferred_delivery", () => false);
override(document, "to_$", () => $("document-stub"));
@ -584,7 +584,7 @@ test_ui("enter_with_preview_open", (override) => {
);
});
test_ui("finish", (override) => {
test_ui("finish", ({override}) => {
override(notifications, "clear_compose_notifications", () => {});
override(reminder, "is_deferred_delivery", () => false);
override(document, "to_$", () => $("document-stub"));
@ -635,7 +635,7 @@ test_ui("finish", (override) => {
})();
});
test_ui("warn_if_private_stream_is_linked", (override) => {
test_ui("warn_if_private_stream_is_linked", ({override}) => {
const test_sub = {
name: compose_state.stream_name(),
stream_id: 99,
@ -707,7 +707,7 @@ test_ui("warn_if_private_stream_is_linked", (override) => {
}
});
test_ui("initialize", (override) => {
test_ui("initialize", ({override}) => {
override(giphy, "is_giphy_enabled", () => true);
let compose_actions_expected_opts;
@ -806,8 +806,8 @@ test_ui("initialize", (override) => {
})();
});
test_ui("update_fade", (override) => {
initialize_handlers(override);
test_ui("update_fade", ({override}) => {
initialize_handlers({override});
const selector =
"#stream_message_recipient_stream,#stream_message_recipient_topic,#private_message_recipient";
@ -836,8 +836,8 @@ test_ui("update_fade", (override) => {
assert.ok(update_all_called);
});
test_ui("trigger_submit_compose_form", (override) => {
initialize_handlers(override);
test_ui("trigger_submit_compose_form", ({override}) => {
initialize_handlers({override});
let prevent_default_checked = false;
let compose_finish_checked = false;
@ -892,7 +892,7 @@ test_ui("needs_subscribe_warning", () => {
assert.equal(compose.needs_subscribe_warning(bob.user_id, sub.stream_id), true);
});
test_ui("warn_if_mentioning_unsubscribed_user", (override) => {
test_ui("warn_if_mentioning_unsubscribed_user", ({override}) => {
override(settings_data, "user_can_subscribe_other_users", () => true);
let mentioned = {
@ -1016,8 +1016,8 @@ test_ui("warn_if_mentioning_unsubscribed_user", (override) => {
assert.ok(looked_for_existing);
});
test_ui("on_events", (override) => {
initialize_handlers(override);
test_ui("on_events", ({override}) => {
initialize_handlers({override});
override(rendered_markdown, "update_elements", () => {});
@ -1370,7 +1370,7 @@ test_ui("on_events", (override) => {
})();
});
test_ui("create_message_object", (override) => {
test_ui("create_message_object", ({override}) => {
$("#stream_message_recipient_stream").val("social");
$("#stream_message_recipient_topic").val("lunch");
$("#compose-textarea").val("burrito");

View File

@ -72,7 +72,7 @@ function assert_hidden(sel) {
assert.ok(!$(sel).visible());
}
function override_private_message_recipient(override) {
function override_private_message_recipient({override}) {
override(
compose_state,
"private_message_recipient",
@ -92,14 +92,14 @@ function override_private_message_recipient(override) {
}
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
// We don't test the css calls; we just skip over them.
$("#compose").css = () => {};
$(".new_message_textarea").css = () => {};
people.init();
compose_state.set_message_type(false);
f(override);
f({override});
});
}
@ -109,8 +109,8 @@ test("initial_state", () => {
assert.equal(compose_state.has_message_content(), false);
});
test("start", (override) => {
override_private_message_recipient(override);
test("start", ({override}) => {
override_private_message_recipient({override});
override(compose_actions, "autosize_message_content", () => {});
override(compose_actions, "expand_compose_box", () => {});
override(compose_actions, "set_focus", () => {});
@ -221,11 +221,11 @@ test("start", (override) => {
assert.ok(!compose_state.composing());
});
test("respond_to_message", (override) => {
test("respond_to_message", ({override}) => {
override(compose_actions, "set_focus", () => {});
override(compose_actions, "complete_starting_tasks", () => {});
override(compose_actions, "clear_textarea", () => {});
override_private_message_recipient(override);
override_private_message_recipient({override});
// Test PM
const person = {
@ -261,12 +261,12 @@ test("respond_to_message", (override) => {
assert.equal($("#stream_message_recipient_stream").val(), "devel");
});
test("reply_with_mention", (override) => {
test("reply_with_mention", ({override}) => {
compose_state.set_message_type("stream");
override(compose_actions, "set_focus", () => {});
override(compose_actions, "complete_starting_tasks", () => {});
override(compose_actions, "clear_textarea", () => {});
override_private_message_recipient(override);
override_private_message_recipient({override});
const msg = {
type: "stream",
@ -307,7 +307,7 @@ test("reply_with_mention", (override) => {
assert.equal(syntax_to_insert, "@**Bob Roberts|40**");
});
test("quote_and_reply", (override) => {
test("quote_and_reply", ({override}) => {
compose_state.set_message_type("stream");
const steve = {
user_id: 90,
@ -319,7 +319,7 @@ test("quote_and_reply", (override) => {
override(compose_actions, "set_focus", () => {});
override(compose_actions, "complete_starting_tasks", () => {});
override(compose_actions, "clear_textarea", () => {});
override_private_message_recipient(override);
override_private_message_recipient({override});
let selected_message;
override(message_lists.current, "selected_message", () => selected_message);
@ -424,7 +424,7 @@ test("get_focus_area", () => {
);
});
test("focus_in_empty_compose", (override) => {
test("focus_in_empty_compose", ({override}) => {
$("#compose-textarea").is = (attr) => {
assert.equal(attr, ":focus");
return $("#compose-textarea").is_focused;
@ -445,7 +445,7 @@ test("focus_in_empty_compose", (override) => {
assert.ok(!compose_state.focus_in_empty_compose());
});
test("on_narrow", (override) => {
test("on_narrow", ({override}) => {
let narrowed_by_topic_reply;
override(narrow_state, "narrowed_by_topic_reply", () => narrowed_by_topic_reply);

View File

@ -17,7 +17,7 @@ let pills = {
pill: {},
};
run_test("pills", (override) => {
run_test("pills", ({override}) => {
override(compose_actions, "update_placeholder_text", () => {});
const othello = {

View File

@ -9,7 +9,7 @@ const compose_pm_pill = mock_esm("../../static/js/compose_pm_pill");
const compose_state = zrequire("compose_state");
run_test("private_message_recipient", (override) => {
run_test("private_message_recipient", ({override}) => {
let emails;
override(compose_pm_pill, "set_from_emails", (value) => {
emails = value;

View File

@ -81,7 +81,7 @@ function make_textbox(s) {
return widget;
}
run_test("autosize_textarea", (override) => {
run_test("autosize_textarea", ({override}) => {
const textarea_autosized = {};
override(autosize, "update", (textarea) => {

View File

@ -55,13 +55,13 @@ people.add_active_user(bob);
function test_ui(label, f) {
// The sloppy_$ flag lets us re-use setup from prior tests.
run_test(label, (override) => {
run_test(label, ({override}) => {
$("#compose-textarea").val("some message");
f(override);
f({override});
});
}
test_ui("validate_stream_message_address_info", (override) => {
test_ui("validate_stream_message_address_info", ({override}) => {
const sub = {
stream_id: 101,
name: "social",
@ -116,7 +116,7 @@ test_ui("validate_stream_message_address_info", (override) => {
);
});
test_ui("validate", (override) => {
test_ui("validate", ({override}) => {
override(compose_actions, "update_placeholder_text", () => {});
override(reminder, "is_deferred_delivery", () => false);
@ -237,7 +237,7 @@ test_ui("validate", (override) => {
);
});
test_ui("get_invalid_recipient_emails", (override) => {
test_ui("get_invalid_recipient_emails", ({override}) => {
const welcome_bot = {
email: "welcome-bot@example.com",
user_id: 124,
@ -257,7 +257,7 @@ test_ui("get_invalid_recipient_emails", (override) => {
assert.deepEqual(compose.get_invalid_recipient_emails(), []);
});
test_ui("validate_stream_message", (override) => {
test_ui("validate_stream_message", ({override}) => {
override(reminder, "is_deferred_delivery", () => false);
// This test is in kind of continuation to test_validate but since it is
@ -308,7 +308,7 @@ test_ui("validate_stream_message", (override) => {
);
});
test_ui("test_validate_stream_message_post_policy_admin_only", (override) => {
test_ui("test_validate_stream_message_post_policy_admin_only", ({override}) => {
override(reminder, "is_deferred_delivery", () => false);
// This test is in continuation with test_validate but it has been separated out
@ -347,7 +347,7 @@ test_ui("test_validate_stream_message_post_policy_admin_only", (override) => {
);
});
test_ui("test_validate_stream_message_post_policy_moderators_only", (override) => {
test_ui("test_validate_stream_message_post_policy_moderators_only", ({override}) => {
override(reminder, "is_deferred_delivery", () => false);
page_params.is_admin = false;
@ -386,7 +386,7 @@ test_ui("test_validate_stream_message_post_policy_moderators_only", (override) =
);
});
test_ui("test_validate_stream_message_post_policy_full_members_only", (override) => {
test_ui("test_validate_stream_message_post_policy_full_members_only", ({override}) => {
override(reminder, "is_deferred_delivery", () => false);
page_params.is_admin = false;

View File

@ -62,13 +62,13 @@ const realm_available_video_chat_providers = {
};
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
page_params.realm_available_video_chat_providers = realm_available_video_chat_providers;
f(override);
f({override});
});
}
test("videos", (override) => {
test("videos", ({override}) => {
page_params.realm_video_chat_provider = realm_available_video_chat_providers.disabled.id;
override(upload, "setup_upload", () => {});
@ -225,7 +225,7 @@ test("videos", (override) => {
})();
});
test("test_video_chat_button_toggle disabled", (override) => {
test("test_video_chat_button_toggle disabled", ({override}) => {
override(upload, "setup_upload", () => {});
override(upload, "feature_check", () => {});
override(render_compose, "f", () => "fake-compose-template");
@ -235,7 +235,7 @@ test("test_video_chat_button_toggle disabled", (override) => {
assert.equal($("#below-compose-content .video_link").visible(), false);
});
test("test_video_chat_button_toggle no url", (override) => {
test("test_video_chat_button_toggle no url", ({override}) => {
override(upload, "setup_upload", () => {});
override(upload, "feature_check", () => {});
override(render_compose, "f", () => "fake-compose-template");
@ -246,7 +246,7 @@ test("test_video_chat_button_toggle no url", (override) => {
assert.equal($("#below-compose-content .video_link").visible(), false);
});
test("test_video_chat_button_toggle enabled", (override) => {
test("test_video_chat_button_toggle enabled", ({override}) => {
override(upload, "setup_upload", () => {});
override(upload, "feature_check", () => {});
override(render_compose, "f", () => "fake-compose-template");

View File

@ -284,7 +284,7 @@ const make_emoji = (emoji_dict) => ({
});
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
people.init();
user_groups.init();
@ -308,11 +308,11 @@ function test(label, f) {
muting.set_muted_users([]);
f(override);
f({override});
});
}
test("topics_seen_for", (override) => {
test("topics_seen_for", ({override}) => {
override(stream_topic_history, "get_recent_topic_names", (stream_id) => {
assert.equal(stream_id, denmark_stream.stream_id);
return ["With Twisted Metal", "acceptance", "civil fears"];
@ -332,7 +332,7 @@ test("topics_seen_for", (override) => {
assert.deepEqual(ct.topics_seen_for("non-existing-stream"), []);
});
test("content_typeahead_selected", (override) => {
test("content_typeahead_selected", ({override}) => {
const fake_this = {
query: "",
$element: {},
@ -575,7 +575,7 @@ function sorted_names_from(subs) {
return subs.map((sub) => sub.name).sort();
}
test("initialize", (override) => {
test("initialize", ({override}) => {
let expected_value;
override(stream_topic_history_util, "get_server_history", () => {});
@ -1128,7 +1128,7 @@ test("initialize", (override) => {
assert.ok(compose_textarea_typeahead_called);
});
test("begins_typeahead", (override) => {
test("begins_typeahead", ({override}) => {
override(stream_topic_history_util, "get_server_history", () => {});
const begin_typehead_this = {
@ -1362,7 +1362,7 @@ test("tokenizing", () => {
assert.equal(ct.tokenize_compose_str("foo #streams@foo"), "#streams@foo");
});
test("content_highlighter", (override) => {
test("content_highlighter", ({override}) => {
let fake_this = {completing: "emoji"};
const emoji = {emoji_name: "person shrugging", emoji_url: "¯\\_(ツ)_/¯"};
let th_render_typeahead_item_called = false;
@ -1521,7 +1521,7 @@ test("typeahead_results", () => {
assert_stream_matches("city", [netherland_stream]);
});
test("message people", (override) => {
test("message people", ({override}) => {
let results;
/*

View File

@ -113,7 +113,7 @@ function assert_same(actual, expected) {
assert.deepEqual(actual, expected);
}
run_test("alert_words", (override) => {
run_test("alert_words", ({override}) => {
alert_words.initialize({alert_words: []});
assert.ok(!alert_words.has_alert_word("fire"));
assert.ok(!alert_words.has_alert_word("lunch"));
@ -127,7 +127,7 @@ run_test("alert_words", (override) => {
assert.ok(alert_words.has_alert_word("lunch"));
});
run_test("attachments", (override) => {
run_test("attachments", ({override}) => {
const event = event_fixtures.attachment__add;
const stub = make_stub();
// attachments_ui is hard to test deeply
@ -137,7 +137,7 @@ run_test("attachments", (override) => {
assert_same(stub.get_args("event").event, event);
});
run_test("user groups", (override) => {
run_test("user groups", ({override}) => {
let event = event_fixtures.user_group__add;
override(settings_user_groups, "reload", noop);
{
@ -195,7 +195,7 @@ run_test("user groups", (override) => {
}
});
run_test("custom profile fields", (override) => {
run_test("custom profile fields", ({override}) => {
const event = event_fixtures.custom_profile_fields;
override(settings_profile_fields, "populate_profile_fields", noop);
override(settings_account, "add_custom_profile_fields_to_settings", noop);
@ -203,7 +203,7 @@ run_test("custom profile fields", (override) => {
assert_same(page_params.custom_profile_fields, event.fields);
});
run_test("default_streams", (override) => {
run_test("default_streams", ({override}) => {
const event = event_fixtures.default_streams;
override(settings_streams, "update_default_streams_table", noop);
const stub = make_stub();
@ -214,7 +214,7 @@ run_test("default_streams", (override) => {
assert_same(args.realm_default_streams, event.default_streams);
});
run_test("hotspots", (override) => {
run_test("hotspots", ({override}) => {
page_params.hotspots = [];
const event = event_fixtures.hotspots;
override(hotspots, "load_new", noop);
@ -222,7 +222,7 @@ run_test("hotspots", (override) => {
assert_same(page_params.hotspots, event.hotspots);
});
run_test("invites_changed", (override) => {
run_test("invites_changed", ({override}) => {
$.create("#admin-invites-list", {children: ["stub"]});
const event = event_fixtures.invites_changed;
const stub = make_stub();
@ -231,7 +231,7 @@ run_test("invites_changed", (override) => {
assert.equal(stub.num_calls, 1);
});
run_test("muted_topics", (override) => {
run_test("muted_topics", ({override}) => {
const event = event_fixtures.muted_topics;
const stub = make_stub();
@ -242,7 +242,7 @@ run_test("muted_topics", (override) => {
assert_same(args.muted_topics, event.muted_topics);
});
run_test("muted_users", (override) => {
run_test("muted_users", ({override}) => {
const event = event_fixtures.muted_users;
const stub = make_stub();
@ -253,7 +253,7 @@ run_test("muted_users", (override) => {
assert_same(args.muted_users, event.muted_users);
});
run_test("presence", (override) => {
run_test("presence", ({override}) => {
const event = event_fixtures.presence;
const stub = make_stub();
@ -266,7 +266,7 @@ run_test("presence", (override) => {
assert_same(args.server_time, event.server_timestamp);
});
run_test("reaction", (override) => {
run_test("reaction", ({override}) => {
let event = event_fixtures.reaction__add;
{
const stub = make_stub();
@ -290,7 +290,7 @@ run_test("reaction", (override) => {
}
});
run_test("realm settings", (override) => {
run_test("realm settings", ({override}) => {
page_params.is_admin = true;
override(settings_org, "sync_realm_settings", noop);
@ -428,7 +428,7 @@ run_test("realm settings", (override) => {
assert_same(window.location.href, "/accounts/deactivated/");
});
run_test("realm_bot add", (override) => {
run_test("realm_bot add", ({override}) => {
const event = event_fixtures.realm_bot__add;
const bot_stub = make_stub();
const admin_stub = make_stub();
@ -444,7 +444,7 @@ run_test("realm_bot add", (override) => {
admin_stub.get_args("update_user_id", "update_bot_data");
});
run_test("realm_bot remove", (override) => {
run_test("realm_bot remove", ({override}) => {
const event = event_fixtures.realm_bot__remove;
const bot_stub = make_stub();
const admin_stub = make_stub();
@ -466,7 +466,7 @@ run_test("realm_bot delete", () => {
dispatch(event);
});
run_test("realm_bot update", (override) => {
run_test("realm_bot update", ({override}) => {
const event = event_fixtures.realm_bot__update;
const bot_stub = make_stub();
const admin_stub = make_stub();
@ -486,7 +486,7 @@ run_test("realm_bot update", (override) => {
assert_same(args.update_user_id, event.bot.user_id);
});
run_test("realm_emoji", (override) => {
run_test("realm_emoji", ({override}) => {
const event = event_fixtures.realm_emoji__update;
const ui_func_names = [
@ -519,7 +519,7 @@ run_test("realm_emoji", (override) => {
}
});
run_test("realm_linkifiers", (override) => {
run_test("realm_linkifiers", ({override}) => {
const event = event_fixtures.realm_linkifiers;
page_params.realm_linkifiers = [];
override(settings_linkifiers, "populate_linkifiers", noop);
@ -528,7 +528,7 @@ run_test("realm_linkifiers", (override) => {
assert_same(page_params.realm_linkifiers, event.realm_linkifiers);
});
run_test("realm_playgrounds", (override) => {
run_test("realm_playgrounds", ({override}) => {
const event = event_fixtures.realm_playgrounds;
page_params.realm_playgrounds = [];
override(settings_playgrounds, "populate_playgrounds", noop);
@ -537,7 +537,7 @@ run_test("realm_playgrounds", (override) => {
assert_same(page_params.realm_playgrounds, event.realm_playgrounds);
});
run_test("realm_domains", (override) => {
run_test("realm_domains", ({override}) => {
let event = event_fixtures.realm_domains__add;
page_params.realm_domains = [];
override(settings_org, "populate_realm_domains", noop);
@ -555,7 +555,7 @@ run_test("realm_domains", (override) => {
assert_same(page_params.realm_domains, []);
});
run_test("realm_user", (override) => {
run_test("realm_user", ({override}) => {
let event = event_fixtures.realm_user__add;
dispatch({...event});
const added_person = people.get_by_user_id(event.person.user_id);
@ -587,7 +587,7 @@ run_test("realm_user", (override) => {
assert_same(args.person, event.person);
});
run_test("restart", (override) => {
run_test("restart", ({override}) => {
const event = event_fixtures.restart;
const stub = make_stub();
override(reload, "initiate", stub.f);
@ -598,7 +598,7 @@ run_test("restart", (override) => {
assert.equal(args.options.immediate, true);
});
run_test("submessage", (override) => {
run_test("submessage", ({override}) => {
const event = event_fixtures.submessage;
const stub = make_stub();
override(submessage, "handle_event", stub.f);
@ -616,7 +616,7 @@ run_test("submessage", (override) => {
// For subscriptions, see dispatch_subs.js
run_test("typing", (override) => {
run_test("typing", ({override}) => {
// Simulate that we are not typing.
page_params.user_id = typing_person1.user_id + 1;
@ -646,7 +646,7 @@ run_test("typing", (override) => {
dispatch(event);
});
run_test("update_display_settings", (override) => {
run_test("update_display_settings", ({override}) => {
let event = event_fixtures.update_display_settings__default_language;
page_params.default_language = "en";
override(settings_display, "update_page", noop);
@ -789,7 +789,7 @@ run_test("update_display_settings", (override) => {
}
});
run_test("update_global_notifications", (override) => {
run_test("update_global_notifications", ({override}) => {
const event = event_fixtures.update_global_notifications;
const stub = make_stub();
override(notifications, "handle_global_notification_updates", stub.f);
@ -801,7 +801,7 @@ run_test("update_global_notifications", (override) => {
assert_same(args.setting, event.setting);
});
run_test("update_message (read)", (override) => {
run_test("update_message (read)", ({override}) => {
const event = event_fixtures.update_message_flags__read;
const stub = make_stub();
@ -812,7 +812,7 @@ run_test("update_message (read)", (override) => {
assert_same(args.message_ids, [999]);
});
run_test("update_message (add star)", (override) => {
run_test("update_message (add star)", ({override}) => {
override(starred_messages, "rerender_ui", noop);
const event = event_fixtures.update_message_flags__starred_add;
@ -827,7 +827,7 @@ run_test("update_message (add star)", (override) => {
assert.equal(msg.starred, true);
});
run_test("update_message (remove star)", (override) => {
run_test("update_message (remove star)", ({override}) => {
override(starred_messages, "rerender_ui", noop);
const event = event_fixtures.update_message_flags__starred_remove;
const stub = make_stub();
@ -841,7 +841,7 @@ run_test("update_message (remove star)", (override) => {
assert.equal(msg.starred, false);
});
run_test("update_message (wrong data)", (override) => {
run_test("update_message (wrong data)", ({override}) => {
override(starred_messages, "rerender_ui", noop);
const event = {
...event_fixtures.update_message_flags__starred_add,
@ -851,7 +851,7 @@ run_test("update_message (wrong data)", (override) => {
// update_starred_view never gets invoked, early return is successful
});
run_test("delete_message", (override) => {
run_test("delete_message", ({override}) => {
const event = event_fixtures.delete_message;
override(stream_list, "update_streams_sidebar", noop);
@ -882,7 +882,7 @@ run_test("delete_message", (override) => {
assert_same(args.opts.max_removed_msg_id, 1337);
});
run_test("user_status", (override) => {
run_test("user_status", ({override}) => {
let event = event_fixtures.user_status__set_away;
{
const stub = make_stub();
@ -916,7 +916,7 @@ run_test("user_status", (override) => {
}
});
run_test("realm_export", (override) => {
run_test("realm_export", ({override}) => {
const event = event_fixtures.realm_export;
const stub = make_stub();
override(settings_exports, "populate_exports_table", stub.f);
@ -927,7 +927,7 @@ run_test("realm_export", (override) => {
assert.equal(args.exports, event.exports);
});
run_test("server_event_dispatch_op_errors", (override) => {
run_test("server_event_dispatch_op_errors", ({override}) => {
blueslip.expect("error", "Unexpected event type subscription/other");
server_events_dispatch.dispatch_normal_event({type: "subscription", op: "other"});
blueslip.expect("error", "Unexpected event type reaction/other");

View File

@ -44,13 +44,13 @@ people.initialize_current_user(me.user_id);
const dispatch = server_events_dispatch.dispatch_normal_event;
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
stream_data.clear_subscriptions();
f(override);
f({override});
});
}
test("add", (override) => {
test("add", ({override}) => {
const event = event_fixtures.subscription__add;
const sub = event.subscriptions[0];
@ -70,7 +70,7 @@ test("add", (override) => {
assert.deepEqual(args.subscribers, event.subscriptions[0].subscribers);
});
test("peer add/remove", (override) => {
test("peer add/remove", ({override}) => {
let event = event_fixtures.subscription__peer_add;
stream_data.add_sub({
@ -98,7 +98,7 @@ test("peer add/remove", (override) => {
assert.ok(!peer_data.is_user_subscribed(event.stream_ids[0], event.user_ids[0]));
});
test("remove", (override) => {
test("remove", ({override}) => {
const event = event_fixtures.subscription__remove;
const event_sub = event.subscriptions[0];
const stream_id = event_sub.stream_id;
@ -118,7 +118,7 @@ test("remove", (override) => {
assert.deepEqual(args.sub, sub);
});
test("update", (override) => {
test("update", ({override}) => {
const event = event_fixtures.subscription__update;
const stub = make_stub();
@ -140,7 +140,7 @@ test("add error handling", () => {
blueslip.reset();
});
test("peer event error handling (bad stream_ids/user_ids)", (override) => {
test("peer event error handling (bad stream_ids/user_ids)", ({override}) => {
override(compose_fade, "update_faded_users", () => {});
const add_event = {
@ -167,7 +167,7 @@ test("peer event error handling (bad stream_ids/user_ids)", (override) => {
dispatch(remove_event);
});
test("stream update", (override) => {
test("stream update", ({override}) => {
const event = event_fixtures.stream__update;
const stub = make_stub();
@ -181,7 +181,7 @@ test("stream update", (override) => {
assert.equal(args.value, event.value);
});
test("stream create", (override) => {
test("stream create", ({override}) => {
const event = event_fixtures.stream__create;
const stub = make_stub();
@ -197,7 +197,7 @@ test("stream create", (override) => {
);
});
test("stream delete (normal)", (override) => {
test("stream delete (normal)", ({override}) => {
const event = event_fixtures.stream__delete;
for (const stream of event.streams) {
@ -238,7 +238,7 @@ test("stream delete (normal)", (override) => {
assert.equal(removed_sidebar_rows, 1);
});
test("stream delete (special streams)", (override) => {
test("stream delete (special streams)", ({override}) => {
const event = event_fixtures.stream__delete;
for (const stream of event.streams) {

View File

@ -83,10 +83,10 @@ const short_msg = {
};
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
$("#draft_overlay").css = () => {};
localStorage.clear();
f(override);
f({override});
});
}
@ -94,7 +94,7 @@ test("legacy", () => {
assert.deepEqual(drafts.restore_message(legacy_draft), compose_args_for_legacy_draft);
});
test("draft_model add", (override) => {
test("draft_model add", ({override}) => {
const draft_model = drafts.draft_model;
const ls = localstorage();
assert.equal(ls.get("draft"), undefined);
@ -129,7 +129,7 @@ test("draft_model edit", () => {
});
});
test("draft_model delete", (override) => {
test("draft_model delete", ({override}) => {
const draft_model = drafts.draft_model;
const ls = localstorage();
assert.equal(ls.get("draft"), undefined);
@ -144,7 +144,7 @@ test("draft_model delete", (override) => {
assert.deepEqual(draft_model.getDraft(id), false);
});
test("snapshot_message", (override) => {
test("snapshot_message", ({override}) => {
let curr_draft;
function map(field, f) {
@ -171,7 +171,7 @@ test("snapshot_message", (override) => {
assert.equal(drafts.snapshot_message(), undefined);
});
test("initialize", (override) => {
test("initialize", ({override}) => {
window.addEventListener = (event_name, f) => {
assert.equal(event_name, "beforeunload");
let called = false;
@ -210,7 +210,7 @@ test("remove_old_drafts", () => {
assert.deepEqual(draft_model.get(), {id3: draft_3});
});
test("format_drafts", (override) => {
test("format_drafts", ({override}) => {
override(drafts, "remove_old_drafts", noop);
function feb12() {

View File

@ -49,7 +49,7 @@ run_test("process_from_server for un-echoed messages", () => {
assert.deepEqual(non_echo_messages, server_messages);
});
run_test("process_from_server for differently rendered messages", (override) => {
run_test("process_from_server for differently rendered messages", ({override}) => {
let messages_to_rerender = [];
override(message_lists.home.view, "rerender_messages", (msgs) => {
@ -190,7 +190,7 @@ run_test("update_message_lists", () => {
assert.equal(view_args.new, 402);
});
run_test("insert_local_message streams", (override) => {
run_test("insert_local_message streams", ({override}) => {
const fake_now = 555;
MockDate.set(new Date(fake_now * 1000));
@ -231,7 +231,7 @@ run_test("insert_local_message streams", (override) => {
assert.ok(insert_message_called);
});
run_test("insert_local_message PM", (override) => {
run_test("insert_local_message PM", ({override}) => {
const local_id_float = 102;
page_params.user_id = 123;

View File

@ -106,7 +106,7 @@ run_test("add users with event", () => {
*/
run_test("update user with event", (override) => {
run_test("update user with event", ({override}) => {
people.init();
people.add_active_user(bob);

View File

@ -59,7 +59,7 @@ people.add_active_user(isaac);
*/
function test_helper(override) {
function test_helper({override}) {
const events = [];
return {
@ -72,12 +72,12 @@ function test_helper(override) {
};
}
run_test("insert_message", (override) => {
run_test("insert_message", ({override}) => {
message_store.clear_for_testing();
override(pm_list, "update_private_messages", () => {});
const helper = test_helper(override);
const helper = test_helper({override});
const new_message = {
sender_id: isaac.user_id,

View File

@ -13,7 +13,7 @@ const {run_test} = require("../zjsunit/test");
second and just explore a contrived example.
*/
run_test("explore make_stub", (override) => {
run_test("explore make_stub", ({override}) => {
// Let's say you have to test the following code.
const app = {

View File

@ -72,7 +72,7 @@ const denmark_stream = {
subscribed: false,
};
run_test("unread_ops", (override) => {
run_test("unread_ops", ({override}) => {
stream_data.clear_subscriptions();
stream_data.add_sub(denmark_stream);
message_store.clear_for_testing();

View File

@ -61,9 +61,9 @@ function make_sub(name, stream_id) {
}
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
stream_data.clear_subscriptions();
f(override);
f({override});
});
}
@ -1263,7 +1263,7 @@ test("term_type", () => {
assert.ok(!filter._build_sorted_term_types_called);
});
test("first_valid_id_from", (override) => {
test("first_valid_id_from", ({override}) => {
const terms = [{operator: "is", operand: "alerted"}];
const filter = new Filter(terms);
@ -1564,7 +1564,7 @@ test("navbar_helpers", () => {
assert.equal(filter.generate_redirect_url(), default_redirect.redirect_url);
});
test("error_cases", (override) => {
test("error_cases", ({override}) => {
// This test just gives us 100% line coverage on defensive code that
// should not be reached unless we break other code.
override(people, "pm_with_user_ids", () => {});

View File

@ -167,7 +167,7 @@ function test_helper({override, change_tab}) {
};
}
run_test("hash_interactions", (override) => {
run_test("hash_interactions", ({override}) => {
window_stub = $.create("window-stub");
page_params.default_view = "recent_topics";
@ -285,7 +285,7 @@ run_test("hash_interactions", (override) => {
helper.assert_events([[ui_util, "blur_active_element"]]);
});
run_test("save_narrow", (override) => {
run_test("save_narrow", ({override}) => {
override(recent_topics_util, "is_visible", () => false);
const helper = test_helper({override});

View File

@ -252,7 +252,7 @@ function test_normal_typing() {
assert_unmapped('~!@#$%^*()_+{}:"<>');
}
run_test("allow normal typing when processing text", (override) => {
run_test("allow normal typing when processing text", ({override}) => {
// Unmapped keys should immediately return false, without
// calling any functions outside of hotkey.js.
assert_unmapped("bfmoyz");
@ -280,7 +280,7 @@ run_test("allow normal typing when processing text", (override) => {
}
});
run_test("streams", (override) => {
run_test("streams", ({override}) => {
settings_data.user_can_create_streams = () => true;
override(overlays, "streams_open", () => true);
override(overlays, "is_active", () => true);
@ -306,19 +306,19 @@ run_test("basic mappings", () => {
assert_mapping("g", gear_menu, "open");
});
run_test("drafts open", (override) => {
run_test("drafts open", ({override}) => {
override(overlays, "is_active", () => true);
override(overlays, "drafts_open", () => true);
assert_mapping("d", overlays, "close_overlay");
});
run_test("drafts closed w/other overlay", (override) => {
run_test("drafts closed w/other overlay", ({override}) => {
override(overlays, "is_active", () => true);
override(overlays, "drafts_open", () => false);
test_normal_typing();
});
run_test("drafts closed launch", (override) => {
run_test("drafts closed launch", ({override}) => {
override(overlays, "is_active", () => false);
assert_mapping("d", browser_history, "go_to_location");
});
@ -359,24 +359,24 @@ run_test("misc", () => {
assert_mapping("e", message_edit, "start");
});
run_test("lightbox overlay open", (override) => {
run_test("lightbox overlay open", ({override}) => {
override(overlays, "is_active", () => true);
override(overlays, "lightbox_open", () => true);
assert_mapping("v", overlays, "close_overlay");
});
run_test("lightbox closed w/other overlay open", (override) => {
run_test("lightbox closed w/other overlay open", ({override}) => {
override(overlays, "is_active", () => true);
override(overlays, "lightbox_open", () => false);
test_normal_typing();
});
run_test("v w/no overlays", (override) => {
run_test("v w/no overlays", ({override}) => {
override(overlays, "is_active", () => false);
assert_mapping("v", lightbox, "show_from_selected_message");
});
run_test("emoji picker", (override) => {
run_test("emoji picker", ({override}) => {
override(emoji_picker, "reactions_popped", () => true);
assert_mapping(":", emoji_picker, "navigate", true);
});

View File

@ -39,7 +39,7 @@ function pill_html(value, data_id, img_src) {
return require("../../static/templates/input_pill.hbs")(opts);
}
function override_random_id(override) {
function override_random_id({override}) {
let id_seq = 0;
override(input_pill, "random_id", () => {
id_seq += 1;
@ -52,8 +52,8 @@ run_test("random_id", () => {
input_pill.random_id();
});
run_test("basics", (override) => {
override_random_id(override);
run_test("basics", ({override}) => {
override_random_id({override});
const config = {};
blueslip.expect("error", "Pill needs container.");
@ -143,8 +143,8 @@ function set_up() {
};
}
run_test("copy from pill", (override) => {
override_random_id(override);
run_test("copy from pill", ({override}) => {
override_random_id({override});
const info = set_up();
const config = info.config;
const container = info.container;
@ -359,8 +359,8 @@ run_test("Enter key with text", () => {
assert.deepEqual(widget.items(), [items.blue, items.red, items.yellow]);
});
run_test("insert_remove", (override) => {
override_random_id(override);
run_test("insert_remove", ({override}) => {
override_random_id({override});
const info = set_up();
const config = info.config;
@ -463,8 +463,8 @@ run_test("insert_remove", (override) => {
assert.ok(next_pill_focused);
});
run_test("exit button on pill", (override) => {
override_random_id(override);
run_test("exit button on pill", ({override}) => {
override_random_id({override});
const info = set_up();
const config = info.config;

View File

@ -24,13 +24,13 @@ const rows = zrequire("rows");
const lightbox = zrequire("lightbox");
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
lightbox.clear_for_testing();
f(override);
f({override});
});
}
test("pan_and_zoom", (override) => {
test("pan_and_zoom", ({override}) => {
const img = $.create("img-stub");
const link = $.create("link-stub");
const msg = $.create("msg-stub");
@ -61,7 +61,7 @@ test("pan_and_zoom", (override) => {
assert.equal(fetched_zid, 1234);
});
test("youtube", (override) => {
test("youtube", ({override}) => {
const href = "https://youtube.com/some-random-clip";
const img = $.create("img-stub");
const link = $.create("link-stub");

View File

@ -31,7 +31,7 @@ function basic_conf({first_key, prev_key, next_key}) {
return conf;
}
run_test("misc errors", (override) => {
run_test("misc errors", ({override}) => {
const conf = basic_conf({
first_key: () => undefined,
prev_key: () => undefined,
@ -60,7 +60,7 @@ run_test("misc errors", (override) => {
cursor.next();
});
run_test("single item list", (override) => {
run_test("single item list", ({override}) => {
const valid_key = "42";
const conf = basic_conf({
@ -89,7 +89,7 @@ run_test("single item list", (override) => {
cursor.go_to(valid_key);
});
run_test("multiple item list", (override) => {
run_test("multiple item list", ({override}) => {
const conf = basic_conf({
first_key: () => 1,
next_key: (key) => (key < 3 ? key + 1 : undefined),

View File

@ -191,10 +191,10 @@ markdown.initialize(markdown_config.get_helpers());
linkifiers.initialize(example_realm_linkifiers);
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
page_params.realm_users = [];
linkifiers.update_linkifier_rules(example_realm_linkifiers);
f(override);
f({override});
});
}
@ -816,7 +816,7 @@ test("translate_emoticons_to_names", () => {
}
});
test("missing unicode emojis", (override) => {
test("missing unicode emojis", ({override}) => {
const message = {raw_content: "\u{1F6B2}"};
markdown.apply_markdown(message);

View File

@ -16,7 +16,7 @@ mock_esm("../../static/js/starred_messages", {
const message_flags = zrequire("message_flags");
run_test("starred", (override) => {
run_test("starred", ({override}) => {
const message = {
id: 50,
};
@ -88,7 +88,7 @@ run_test("starring local echo", () => {
});
});
run_test("unstar_all", (override) => {
run_test("unstar_all", ({override}) => {
// Way to capture posted info in every request
let posted_data;
override(channel, "post", (opts) => {
@ -104,7 +104,7 @@ run_test("unstar_all", (override) => {
assert.deepEqual(posted_data, expected_data);
});
run_test("unstar_all_in_topic", (override) => {
run_test("unstar_all_in_topic", ({override}) => {
// Way to capture posted info in every request
let channel_post_opts;
let channel_get_opts;
@ -142,7 +142,7 @@ run_test("unstar_all_in_topic", (override) => {
});
});
run_test("read", (override) => {
run_test("read", ({override}) => {
// Way to capture posted info in every request
let channel_post_opts;
override(channel, "post", (opts) => {
@ -261,7 +261,7 @@ run_test("read", (override) => {
});
});
run_test("read_empty_data", (override) => {
run_test("read_empty_data", ({override}) => {
// Way to capture posted info in every request
let channel_post_opts;
override(channel, "post", (opts) => {
@ -289,7 +289,7 @@ run_test("read_empty_data", (override) => {
assert.deepEqual(channel_post_opts, {});
});
run_test("collapse_and_uncollapse", (override) => {
run_test("collapse_and_uncollapse", ({override}) => {
// Way to capture posted info in every request
let channel_post_opts;
override(channel, "post", (opts) => {

View File

@ -30,7 +30,7 @@ const stream_data = mock_esm("../../static/js/stream_data");
const {MessageList} = zrequire("message_list");
const {Filter} = zrequire("filter");
run_test("basics", (override) => {
run_test("basics", ({override}) => {
const filter = new Filter();
const list = new MessageList({
@ -300,7 +300,7 @@ run_test("local_echo", () => {
assert.equal(list.closest_id(50.01), 50.01);
});
run_test("bookend", (override) => {
run_test("bookend", ({override}) => {
const list = new MessageList({});
let expected = "translated: You subscribed to stream IceCream";

View File

@ -52,9 +52,9 @@ const muting = zrequire("muting");
let next_timestamp = 1500000000;
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
muting.set_muted_users([]);
f(override);
f({override});
});
}

View File

@ -88,10 +88,10 @@ function convert_recipients(people) {
}
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
message_store.clear_for_testing();
message_user_ids.clear_for_testing();
f(override);
f({override});
});
}

View File

@ -41,10 +41,10 @@ stream_data.add_sub(office);
stream_data.add_sub(social);
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
muting.set_muted_topics([]);
muting.set_muted_users([]);
f(override);
f({override});
});
}

View File

@ -359,7 +359,7 @@ run_test("narrow_to_compose_target errors", () => {
test();
});
run_test("narrow_to_compose_target streams", (override) => {
run_test("narrow_to_compose_target streams", ({override}) => {
const args = {called: false};
override(narrow, "activate", (operators, opts) => {
args.operators = operators;
@ -405,7 +405,7 @@ run_test("narrow_to_compose_target streams", (override) => {
assert.deepEqual(args.operators, [{operator: "stream", operand: "ROME"}]);
});
run_test("narrow_to_compose_target PMs", (override) => {
run_test("narrow_to_compose_target PMs", ({override}) => {
const args = {called: false};
override(narrow, "activate", (operators, opts) => {
args.operators = operators;

View File

@ -19,10 +19,10 @@ function set_filter(operators) {
}
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
narrow_state.reset_current_filter();
stream_data.clear_subscriptions();
f(override);
f({override});
});
}

View File

@ -191,7 +191,7 @@ run_test("get_unread_ids", () => {
});
});
run_test("defensive code", (override) => {
run_test("defensive code", ({override}) => {
// Test defensive code. We actually avoid calling
// _possible_unread_message_ids for any case where we
// couldn't compute the unread message ids, but that

View File

@ -40,9 +40,9 @@ const notifications = zrequire("notifications");
const util = zrequire("util");
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
localStorage.clear();
f(override);
f({override});
});
}
@ -95,7 +95,7 @@ test("profile_incomplete_alert", () => {
assert.equal(navbar_alerts.check_profile_incomplete(), false);
});
test("server_upgrade_alert hide_duration_expired", (override) => {
test("server_upgrade_alert hide_duration_expired", ({override}) => {
const ls = localstorage();
const start_time = new Date(1620327447050); // Thursday 06/5/2021 07:02:27 AM (UTC+0)

View File

@ -53,14 +53,14 @@ stream_data.add_sub(muted);
muting.add_muted_topic(general.stream_id, "muted topic");
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
page_params.is_admin = false;
page_params.realm_users = [];
page_params.enable_desktop_notifications = true;
page_params.enable_sounds = true;
page_params.wildcard_mentions_notify = true;
page_params.notification_sound = "ding";
f(override);
f({override});
});
}
@ -283,7 +283,7 @@ test("message_is_notifiable", () => {
assert.equal(notifications.message_is_notifiable(message), true);
});
test("basic_notifications", (override) => {
test("basic_notifications", ({override}) => {
override(ui, "replace_emoji_with_text", () => {});
let n; // Object for storing all notification data for assertions.

View File

@ -49,7 +49,7 @@ function contains_sub(subs, sub) {
}
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
peer_data.clear_for_testing();
stream_data.clear_subscriptions();
@ -57,7 +57,7 @@ function test(label, f) {
people.add_active_user(me);
people.initialize_current_user(me.user_id);
f(override);
f({override});
});
}

View File

@ -62,9 +62,9 @@ function initialize() {
}
function test_people(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
initialize();
f(override);
f({override});
});
}
@ -814,7 +814,7 @@ test_people("message_methods", () => {
assert.equal(people.sender_is_guest(message), false);
});
test_people("extract_people_from_message", (override) => {
test_people("extract_people_from_message", ({override}) => {
let message = {
type: "stream",
sender_full_name: maria.full_name,
@ -905,7 +905,7 @@ test_people("slugs", () => {
assert.equal(people.emails_to_slug("does@not.exist"), undefined);
});
test_people("get_people_for_search_bar", (override) => {
test_people("get_people_for_search_bar", ({override}) => {
let user_ids;
override(message_user_ids, "user_ids", () => user_ids);

View File

@ -23,7 +23,7 @@ people.init();
people.add_active_user(me);
people.initialize_current_user(me.user_id);
run_test("report_late_add", (override) => {
run_test("report_late_add", ({override}) => {
blueslip.expect("error", "Added user late: user_id=55 email=foo@example.com");
people.report_late_add(55, "foo@example.com");
@ -40,7 +40,7 @@ run_test("is_my_user_id", () => {
assert.equal(people.is_my_user_id(me.user_id.toString()), true);
});
run_test("blueslip", (override) => {
run_test("blueslip", ({override}) => {
const unknown_email = "alicebobfred@example.com";
blueslip.expect("debug", "User email operand unknown: " + unknown_email);

View File

@ -20,12 +20,12 @@ const params = {
};
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
pmc.clear_for_testing();
muting.set_muted_topics([]);
muting.set_muted_users([]);
people.initialize_current_user(15);
f(override);
f({override});
});
}

View File

@ -54,10 +54,10 @@ people.add_active_user(bot_test);
people.initialize_current_user(me.user_id);
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
pm_conversations.clear_for_testing();
pm_list.clear_for_testing();
f(override);
f({override});
});
}
@ -70,7 +70,7 @@ test("close", () => {
assert.ok(collapsed);
});
test("build_private_messages_list", (override) => {
test("build_private_messages_list", ({override}) => {
const timestamp = 0;
pm_conversations.recent.insert([101, 102], timestamp);
@ -111,7 +111,7 @@ test("build_private_messages_list", (override) => {
assert.deepEqual(pm_data, expected_data);
});
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);
@ -152,7 +152,7 @@ test("build_private_messages_list_bot", (override) => {
assert.deepEqual(pm_data, expected_data);
});
test("update_dom_with_unread_counts", (override) => {
test("update_dom_with_unread_counts", ({override}) => {
let counts;
override(narrow_state, "active", () => true);
@ -178,7 +178,7 @@ test("update_dom_with_unread_counts", (override) => {
assert.ok(!total_count.visible());
});
test("get_active_user_ids_string", (override) => {
test("get_active_user_ids_string", ({override}) => {
let active_filter;
override(narrow_state, "filter", () => active_filter);
@ -210,7 +210,7 @@ function private_filter() {
};
}
test("is_all_privates", (override) => {
test("is_all_privates", ({override}) => {
let filter;
override(narrow_state, "filter", () => filter);
@ -221,7 +221,7 @@ test("is_all_privates", (override) => {
assert.equal(pm_list.is_all_privates(), true);
});
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");
@ -237,7 +237,7 @@ test("expand", (override) => {
assert.ok($(".top_left_private_messages").hasClass("active-filter"));
});
test("update_private_messages", (override) => {
test("update_private_messages", ({override}) => {
let html_updated;
let container_found;
@ -264,7 +264,7 @@ test("update_private_messages", (override) => {
assert.ok(container_found);
});
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);

View File

@ -211,7 +211,7 @@ run_test("wrong person editing question", () => {
});
});
run_test("activate another person poll", (override) => {
run_test("activate another person poll", ({override}) => {
override(render_poll_widget, "f", () => "widgets/poll_widget");
override(render_poll_widget_results, "f", () => "widgets/poll_widget_results");
@ -326,7 +326,7 @@ run_test("activate another person poll", (override) => {
widget_elem.handle_events(add_question_event);
});
run_test("activate own poll", (override) => {
run_test("activate own poll", ({override}) => {
override(render_poll_widget, "f", () => "widgets/poll_widget");
override(render_poll_widget_results, "f", () => "widgets/poll_widget_results");

View File

@ -109,18 +109,18 @@ function make_image_stubber() {
}
function test_ui(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
page_params.is_admin = false;
page_params.realm_email_address_visibility = 3;
page_params.custom_profile_fields = [];
override(popovers, "clipboard_enable", noop);
popovers.clear_for_testing();
popovers.register_click_handlers();
f(override);
f({override});
});
}
test_ui("sender_hover", (override) => {
test_ui("sender_hover", ({override}) => {
override($.fn, "popover", noop);
const selection = ".sender_name, .sender_name-in-status, .inline_profile_picture";
@ -214,7 +214,7 @@ test_ui("sender_hover", (override) => {
// todo: load image
});
test_ui("actions_popover", (override) => {
test_ui("actions_popover", ({override}) => {
override($.fn, "popover", noop);
const target = $.create("click target");

View File

@ -76,9 +76,9 @@ people.add_active_user(jane);
people.initialize_current_user(me.user_id);
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
presence.clear_internal_data();
f(override);
f({override});
});
}
@ -86,7 +86,7 @@ test("my user", () => {
assert.equal(presence.get_status(me.user_id), "active");
});
test("unknown user", (override) => {
test("unknown user", ({override}) => {
const unknown_user_id = 999;
const now = 888888;
const presences = {};

View File

@ -119,9 +119,9 @@ people.add_active_user(cali);
people.add_active_user(alexus);
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
page_params.user_id = alice_user_id;
f(override);
f({override});
});
}
@ -255,7 +255,7 @@ test("unknown realm emojis (insert)", () => {
});
});
test("sending", (override) => {
test("sending", ({override}) => {
const message = {...sample_message};
assert.equal(message.id, 1001);
override(message_store, "get", (message_id) => {
@ -354,7 +354,7 @@ test("set_reaction_count", () => {
assert.equal(count_element.text(), "5");
});
test("find_reaction", (override) => {
test("find_reaction", ({override}) => {
const message_id = 99;
const local_id = "unicode_emoji,1f44b";
const reaction_section = $.create("section-stub");
@ -386,7 +386,7 @@ test("get_reaction_section", () => {
assert.equal(section, message_reactions);
});
test("emoji_reaction_title", (override) => {
test("emoji_reaction_title", ({override}) => {
const message = {...sample_message};
override(message_store, "get", () => message);
const local_id = "unicode_emoji,1f642";
@ -397,7 +397,7 @@ test("emoji_reaction_title", (override) => {
);
});
test("add_reaction/remove_reaction", (override) => {
test("add_reaction/remove_reaction", ({override}) => {
// This function tests reaction events by mocking out calls to
// the view.
@ -573,7 +573,7 @@ test("add_reaction/remove_reaction", (override) => {
});
});
test("view.insert_new_reaction (me w/unicode emoji)", (override) => {
test("view.insert_new_reaction (me w/unicode emoji)", ({override}) => {
const opts = {
message_id: 501,
reaction_type: "unicode_emoji",
@ -618,7 +618,7 @@ test("view.insert_new_reaction (me w/unicode emoji)", (override) => {
assert.ok(insert_called);
});
test("view.insert_new_reaction (them w/zulip emoji)", (override) => {
test("view.insert_new_reaction (them w/zulip emoji)", ({override}) => {
const zulip_emoji = emoji_params.realm_emoji.zulip;
const opts = {
message_id: 502,
@ -667,7 +667,7 @@ test("view.insert_new_reaction (them w/zulip emoji)", (override) => {
assert.ok(insert_called);
});
test("view.update_existing_reaction (me)", (override) => {
test("view.update_existing_reaction (me)", ({override}) => {
const opts = {
message_id: 503,
reaction_type: "unicode_emoji",
@ -699,7 +699,7 @@ test("view.update_existing_reaction (me)", (override) => {
);
});
test("view.update_existing_reaction (them)", (override) => {
test("view.update_existing_reaction (them)", ({override}) => {
const opts = {
message_id: 504,
reaction_type: "unicode_emoji",
@ -731,7 +731,7 @@ test("view.update_existing_reaction (them)", (override) => {
);
});
test("view.remove_reaction (me)", (override) => {
test("view.remove_reaction (me)", ({override}) => {
const opts = {
message_id: 505,
reaction_type: "unicode_emoji",
@ -764,7 +764,7 @@ test("view.remove_reaction (me)", (override) => {
);
});
test("view.remove_reaction (them)", (override) => {
test("view.remove_reaction (them)", ({override}) => {
const opts = {
message_id: 506,
reaction_type: "unicode_emoji",
@ -798,7 +798,7 @@ test("view.remove_reaction (them)", (override) => {
);
});
test("view.remove_reaction (last person)", (override) => {
test("view.remove_reaction (last person)", ({override}) => {
const opts = {
message_id: 507,
reaction_type: "unicode_emoji",
@ -824,7 +824,7 @@ test("view.remove_reaction (last person)", (override) => {
assert.ok(removed);
});
test("error_handling", (override) => {
test("error_handling", ({override}) => {
override(message_store, "get", () => {});
blueslip.expect("error", "reactions: Bad message id: 55");
@ -843,7 +843,7 @@ test("error_handling", (override) => {
reactions.remove_reaction(bogus_event);
});
test("remove spurious user", (override) => {
test("remove spurious user", ({override}) => {
// get coverage for removing non-user (it should just
// silently fail)
@ -861,7 +861,7 @@ test("remove spurious user", (override) => {
reactions.remove_reaction(event);
});
test("remove last user", (override) => {
test("remove last user", ({override}) => {
const message = {...sample_message};
override(message_store, "get", () => message);
@ -897,7 +897,7 @@ test("local_reaction_id", () => {
assert.equal(local_id, "unicode_emoji,1f44d");
});
test("process_reaction_click", (override) => {
test("process_reaction_click", ({override}) => {
override(reactions.view, "remove_reaction", () => {});
const message = {...sample_message};
@ -944,7 +944,7 @@ test("warnings", () => {
reactions.get_message_reactions(message);
});
test("code coverage", (override) => {
test("code coverage", ({override}) => {
/*
We just silently fail in a few places in the reaction
code, since events may come for messages that we don't
@ -982,14 +982,14 @@ test("duplicates", () => {
reactions.set_clean_reactions(dup_reaction_message);
});
test("process_reaction_click undefined", (override) => {
test("process_reaction_click undefined", ({override}) => {
override(message_store, "get", () => undefined);
blueslip.expect("error", "reactions: Bad message id: 55");
blueslip.expect("error", "message_id for reaction click is unknown: 55");
reactions.process_reaction_click(55, "whatever");
});
test("process_reaction_click bad local id", (override) => {
test("process_reaction_click bad local id", ({override}) => {
const stub_message = {id: 4001, reactions: []};
override(message_store, "get", () => stub_message);
blueslip.expect(

View File

@ -31,11 +31,11 @@ const rs = zrequire("recent_senders");
zrequire("message_util.js");
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
messages.clear();
next_id = 0;
rs.clear_for_testing();
f(override);
f({override});
});
}

View File

@ -339,15 +339,15 @@ function stub_out_filter_buttons() {
}
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
$(".header").css = () => {};
messages = sample_messages.map((message) => ({...message}));
f(override);
f({override});
});
}
test("test_recent_topics_show", (override) => {
test("test_recent_topics_show", ({override}) => {
// Note: unread count and urls are fake,
// since they are generated in external libraries
// and are not to be tested here.
@ -376,7 +376,7 @@ test("test_recent_topics_show", (override) => {
assert.equal(rt.inplace_rerender("stream_unknown:topic_unknown"), false);
});
test("test_filter_all", (override) => {
test("test_filter_all", ({override}) => {
// Just tests inplace rerender of a message
// in All topics filter.
const expected = {
@ -426,7 +426,7 @@ test("test_filter_all", (override) => {
assert.equal(rt.inplace_rerender("1:topic-1"), true);
});
test("test_filter_unread", (override) => {
test("test_filter_unread", ({override}) => {
let expected_filter_unread = false;
override(render_recent_topics_table, "f", (data) => {
@ -533,7 +533,7 @@ test("test_filter_unread", (override) => {
rt.set_filter("all");
});
test("test_filter_participated", (override) => {
test("test_filter_participated", ({override}) => {
let expected_filter_participated;
override(render_recent_topics_table, "f", (data) => {
@ -650,7 +650,7 @@ test("test_update_unread_count", () => {
rt.update_topic_unread_count(messages[9]);
});
test("basic assertions", (override) => {
test("basic assertions", ({override}) => {
rt.clear_for_tests();
override(render_recent_topics_table, "f", () => {});
@ -772,7 +772,7 @@ test("basic assertions", (override) => {
assert.equal(rt.update_topic_is_muted(stream1, "topic-10"), false);
});
test("test_reify_local_echo_message", (override) => {
test("test_reify_local_echo_message", ({override}) => {
override(render_recent_topics_table, "f", () => {});
override(render_recent_topic_row, "f", () => {});
@ -824,7 +824,7 @@ test("test_reify_local_echo_message", (override) => {
);
});
test("test_delete_messages", (override) => {
test("test_delete_messages", ({override}) => {
rt.clear_for_tests();
stub_out_filter_buttons();
rt.set_filter("all");
@ -862,7 +862,7 @@ test("test_delete_messages", (override) => {
rt.update_topics_of_deleted_message_ids([-1]);
});
test("test_topic_edit", (override) => {
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.

View File

@ -8,9 +8,9 @@ const {run_test} = require("../zjsunit/test");
const reload_state = zrequire("reload_state");
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
reload_state.clear_for_testing();
f(override);
f({override});
});
}

View File

@ -425,7 +425,7 @@ function test_code_playground(override, viewing_code) {
};
}
run_test("code playground none", (override) => {
run_test("code playground none", ({override}) => {
override(realm_playground, "get_playground_info_for_languages", (language) => {
assert.equal(language, "javascript");
return undefined;
@ -439,7 +439,7 @@ run_test("code playground none", (override) => {
assert.equal(view_code.attr("aria-label"), undefined);
});
run_test("code playground single", (override) => {
run_test("code playground single", ({override}) => {
override(realm_playground, "get_playground_info_for_languages", (language) => {
assert.equal(language, "javascript");
return [{name: "Some Javascript Playground"}];
@ -457,7 +457,7 @@ run_test("code playground single", (override) => {
assert.equal(view_code.attr("aria-haspopup"), undefined);
});
run_test("code playground multiple", (override) => {
run_test("code playground multiple", ({override}) => {
override(realm_playground, "get_playground_info_for_languages", (language) => {
assert.equal(language, "javascript");
return ["whatever", "whatever"];

View File

@ -33,9 +33,9 @@ const search_pill = zrequire("search_pill");
const {Filter} = zrequire("../js/filter");
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
page_params.search_pills_enabled = true;
f(override);
f({override});
});
}

View File

@ -70,7 +70,7 @@ run_test("get_items", () => {
);
});
run_test("create_pills", (override) => {
run_test("create_pills", ({override}) => {
let input_pill_create_called = false;
override(input_pill, "create", () => {

View File

@ -76,13 +76,13 @@ function get_suggestions(base_query, query) {
}
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
init();
f(override);
f({override});
});
}
test("basic_get_suggestions", (override) => {
test("basic_get_suggestions", ({override}) => {
const query = "fred";
override(stream_data, "subscribed_streams", () => []);
@ -352,7 +352,7 @@ test("group_suggestions", () => {
assert.deepEqual(suggestions.strings, expected);
});
test("empty_query_suggestions", (override) => {
test("empty_query_suggestions", ({override}) => {
const query = "";
override(stream_data, "subscribed_streams", () => ["devel", "office"]);
@ -391,7 +391,7 @@ test("empty_query_suggestions", (override) => {
assert.equal(describe("has:attachment"), "Messages with one or more attachment");
});
test("has_suggestions", (override) => {
test("has_suggestions", ({override}) => {
// Checks that category wise suggestions are displayed instead of a single
// default suggestion when suggesting `has` operator.
let query = "h";
@ -447,7 +447,7 @@ test("has_suggestions", (override) => {
assert.deepEqual(suggestions.strings, expected);
});
test("check_is_suggestions", (override) => {
test("check_is_suggestions", ({override}) => {
let query = "i";
override(stream_data, "subscribed_streams", () => ["devel", "office"]);
override(narrow_state, "stream", () => {});
@ -551,7 +551,7 @@ test("check_is_suggestions", (override) => {
assert.deepEqual(suggestions.strings, expected);
});
test("sent_by_me_suggestions", (override) => {
test("sent_by_me_suggestions", ({override}) => {
override(stream_data, "subscribed_streams", () => []);
override(narrow_state, "stream", () => {});
@ -627,7 +627,7 @@ test("sent_by_me_suggestions", (override) => {
assert.deepEqual(suggestions.strings, expected);
});
test("topic_suggestions", (override) => {
test("topic_suggestions", ({override}) => {
let suggestions;
let expected;
@ -716,7 +716,7 @@ test("topic_suggestions", (override) => {
assert.deepEqual(suggestions.strings, expected);
});
test("whitespace_glitch", (override) => {
test("whitespace_glitch", ({override}) => {
const query = "stream:office "; // note trailing space
override(stream_data, "subscribed_streams", () => ["office"]);
@ -728,7 +728,7 @@ test("whitespace_glitch", (override) => {
assert.deepEqual(suggestions.strings, expected);
});
test("stream_completion", (override) => {
test("stream_completion", ({override}) => {
override(stream_data, "subscribed_streams", () => ["office", "dev help"]);
override(narrow_state, "stream", () => {});
@ -772,7 +772,7 @@ function people_suggestion_setup() {
people.add_active_user(alice);
}
test("people_suggestions", (override) => {
test("people_suggestions", ({override}) => {
override(narrow_state, "stream", noop);
people_suggestion_setup();
@ -836,7 +836,7 @@ test("people_suggestions", (override) => {
assert.deepEqual(suggestions.strings, expected);
});
test("people_suggestion (Admin only email visibility)", (override) => {
test("people_suggestion (Admin only email visibility)", ({override}) => {
/* Suggestions when realm_email_address_visibility is set to admin
only */
override(narrow_state, "stream", noop);
@ -897,7 +897,7 @@ test("operator_suggestions", () => {
assert.deepEqual(suggestions.strings, expected);
});
test("queries_with_spaces", (override) => {
test("queries_with_spaces", ({override}) => {
override(stream_data, "subscribed_streams", () => ["office", "dev help"]);
// test allowing spaces with quotes surrounding operand

View File

@ -74,13 +74,13 @@ function get_suggestions(base_query, query) {
}
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
init();
f(override);
f({override});
});
}
test("basic_get_suggestions", (override) => {
test("basic_get_suggestions", ({override}) => {
const query = "fred";
override(stream_data, "subscribed_streams", () => []);
@ -356,7 +356,7 @@ test("group_suggestions", () => {
assert.deepEqual(suggestions.strings, expected);
});
test("empty_query_suggestions", (override) => {
test("empty_query_suggestions", ({override}) => {
const query = "";
override(stream_data, "subscribed_streams", () => ["devel", "office"]);
@ -395,7 +395,7 @@ test("empty_query_suggestions", (override) => {
assert.equal(describe("has:attachment"), "Messages with one or more attachment");
});
test("has_suggestions", (override) => {
test("has_suggestions", ({override}) => {
// Checks that category wise suggestions are displayed instead of a single
// default suggestion when suggesting `has` operator.
let query = "h";
@ -454,7 +454,7 @@ test("has_suggestions", (override) => {
assert.deepEqual(suggestions.strings, expected);
});
test("check_is_suggestions", (override) => {
test("check_is_suggestions", ({override}) => {
override(stream_data, "subscribed_streams", () => ["devel", "office"]);
override(narrow_state, "stream", () => {});
@ -523,7 +523,7 @@ test("check_is_suggestions", (override) => {
assert.deepEqual(suggestions.strings, expected);
});
test("sent_by_me_suggestions", (override) => {
test("sent_by_me_suggestions", ({override}) => {
override(stream_data, "subscribed_streams", () => []);
override(narrow_state, "stream", () => {});
@ -594,7 +594,7 @@ test("sent_by_me_suggestions", (override) => {
assert.deepEqual(suggestions.strings, expected);
});
test("topic_suggestions", (override) => {
test("topic_suggestions", ({override}) => {
let suggestions;
let expected;
@ -689,7 +689,7 @@ test("topic_suggestions", (override) => {
assert.deepEqual(suggestions.strings, expected);
});
test("whitespace_glitch", (override) => {
test("whitespace_glitch", ({override}) => {
const query = "stream:office "; // note trailing space
override(stream_data, "subscribed_streams", () => ["office"]);
@ -701,7 +701,7 @@ test("whitespace_glitch", (override) => {
assert.deepEqual(suggestions.strings, expected);
});
test("stream_completion", (override) => {
test("stream_completion", ({override}) => {
override(stream_data, "subscribed_streams", () => ["office", "dev help"]);
override(narrow_state, "stream", () => {});
@ -722,7 +722,7 @@ test("stream_completion", (override) => {
assert.deepEqual(suggestions.strings, expected);
});
test("people_suggestions", (override) => {
test("people_suggestions", ({override}) => {
let query = "te";
override(stream_data, "subscribed_streams", () => []);
@ -836,7 +836,7 @@ test("operator_suggestions", () => {
assert.deepEqual(suggestions.strings, expected);
});
test("queries_with_spaces", (override) => {
test("queries_with_spaces", ({override}) => {
override(stream_data, "subscribed_streams", () => ["office", "dev help"]);
// test allowing spaces with quotes surrounding operand

View File

@ -66,7 +66,7 @@ const server_events = zrequire("server_events");
server_events.home_view_loaded();
run_test("message_event", (override) => {
run_test("message_event", ({override}) => {
const event = {
type: "message",
message: {

View File

@ -33,7 +33,7 @@ const settings_bots = zrequire("settings_bots");
bot_data.initialize(bot_data_params);
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
page_params.realm_uri = "https://chat.example.com";
page_params.realm_embedded_bots = [
{name: "converter", config: {}},
@ -41,7 +41,7 @@ function test(label, f) {
{name: "foobot", config: {bar: "baz", qux: "quux"}},
];
f(override);
f({override});
});
}
@ -120,7 +120,7 @@ function test_create_bot_type_input_box_toggle(f) {
assert.ok(!config_inputbox.visible());
}
test("test tab clicks", (override) => {
test("test tab clicks", ({override}) => {
override($.validator, "addMethod", () => {});
$("#create_bot_form").validate = () => {};

View File

@ -21,7 +21,7 @@ const frontend = {
};
stream_data.add_sub(frontend);
run_test("settings", (override) => {
run_test("settings", ({override}) => {
muting.add_muted_topic(frontend.stream_id, "js", 1577836800);
let populate_list_called = false;
override(settings_muted_topics, "populate_list", () => {

View File

@ -14,7 +14,7 @@ const muting = zrequire("muting");
const noop = () => {};
run_test("settings", (override) => {
run_test("settings", ({override}) => {
muting.add_muted_user(5, 1577836800);
let populate_list_called = false;
override(settings_muted_users, "populate_list", () => {

View File

@ -56,7 +56,7 @@ const sub_store = zrequire("sub_store");
const dropdown_list_widget = zrequire("dropdown_list_widget");
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
$("#realm-icon-upload-widget .upload-spinner-background").css = () => {};
page_params.is_admin = false;
page_params.realm_domains = [
@ -65,7 +65,7 @@ function test(label, f) {
];
page_params.realm_authentication_methods = {};
settings_org.reset();
f(override);
f({override});
});
}
@ -643,7 +643,7 @@ function test_discard_changes_button(discard_changes) {
settings_org.__Rewire__("change_save_button_state", stubbed_function);
}
test("set_up", (override) => {
test("set_up", ({override}) => {
override(render_settings_admin_realm_domains_list, "f", () => "stub-domains-list");
const verify_realm_domains = simulate_realm_domains_table();
page_params.realm_available_video_chat_providers = {
@ -826,7 +826,7 @@ test("test get_sorted_options_list", () => {
assert.deepEqual(settings_org.get_sorted_options_list(option_values_2), expected_option_values);
});
test("misc", (override) => {
test("misc", ({override}) => {
page_params.is_admin = false;
const stub_notification_disable_parent = $.create("<stub notification_disable parent");

View File

@ -69,7 +69,7 @@ function test_populate(opts, template_data) {
assert.equal(num_appends, fields_data.length);
}
run_test("populate_profile_fields", (override) => {
run_test("populate_profile_fields", ({override}) => {
page_params.custom_profile_fields = {};
page_params.realm_default_external_accounts = JSON.stringify({});

View File

@ -99,7 +99,7 @@ const name_selector = `#user-groups #${CSS.escape(1)} .name`;
const description_selector = `#user-groups #${CSS.escape(1)} .description`;
const instructions_selector = `#user-groups #${CSS.escape(1)} .save-instructions`;
test_ui("populate_user_groups", (override) => {
test_ui("populate_user_groups", ({override}) => {
const realm_user_group = {
id: 1,
name: "Mobile",
@ -351,7 +351,7 @@ test_ui("populate_user_groups", (override) => {
"function",
);
});
test_ui("with_external_user", (override) => {
test_ui("with_external_user", ({override}) => {
const realm_user_group = {
id: 1,
name: "Mobile",
@ -485,7 +485,7 @@ test_ui("with_external_user", (override) => {
assert.equal(turned_off["click/whole"], true);
});
test_ui("reload", (override) => {
test_ui("reload", ({override}) => {
$("#user-groups").html("Some text");
let populate_user_groups_called = false;
override(settings_user_groups, "populate_user_groups", () => {
@ -502,7 +502,7 @@ test_ui("reset", () => {
assert.equal(result, undefined);
});
test_ui("on_events", (override) => {
test_ui("on_events", ({override}) => {
override(settings_user_groups, "can_edit", () => true);
(function test_admin_user_group_form_submit_triggered() {

View File

@ -12,7 +12,7 @@ const starred_messages = zrequire("starred_messages");
const stream_popover = zrequire("stream_popover");
const top_left_corner = zrequire("top_left_corner");
run_test("add starred", (override) => {
run_test("add starred", ({override}) => {
starred_messages.starred_ids.clear();
assert.deepEqual(starred_messages.get_starred_msg_ids(), []);
assert.equal(starred_messages.get_count(), 0);
@ -23,7 +23,7 @@ run_test("add starred", (override) => {
assert.equal(starred_messages.get_count(), 2);
});
run_test("remove starred", (override) => {
run_test("remove starred", ({override}) => {
starred_messages.starred_ids.clear();
assert.deepEqual(starred_messages.get_starred_msg_ids(), []);
@ -77,7 +77,7 @@ run_test("get starred ids in topic", () => {
assert.deepEqual(starred_messages.get_count_in_topic(20, "topic"), 1);
});
run_test("initialize", (override) => {
run_test("initialize", ({override}) => {
starred_messages.starred_ids.clear();
for (const id of [1, 2, 3]) {
starred_messages.starred_ids.add(id);

View File

@ -29,7 +29,7 @@ function contains_sub(subs, sub) {
}
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
page_params.is_admin = false;
page_params.realm_users = [];
page_params.is_guest = false;
@ -37,7 +37,7 @@ function test(label, f) {
people.add_active_user(me);
people.initialize_current_user(me.user_id);
stream_data.clear_subscriptions();
f(override);
f({override});
});
}
@ -641,7 +641,7 @@ test("canonicalized_name", () => {
assert.deepStrictEqual(stream_data.canonicalized_name("Stream_Bar"), "stream_bar");
});
test("create_sub", (override) => {
test("create_sub", ({override}) => {
const india = {
stream_id: 102,
name: "India",

View File

@ -104,14 +104,14 @@ for (const sub of subs) {
}
function test_ui(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
page_params.user_id = me.user_id;
stream_edit.initialize();
f(override);
f({override});
});
}
test_ui("subscriber_pills", (override) => {
test_ui("subscriber_pills", ({override}) => {
override(stream_edit, "sort_but_pin_current_user_on_top", noop);
override(render_subscription_settings, "f", () => "subscription_settings");

View File

@ -85,13 +85,13 @@ function narrow_to_frontend() {
}
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
stream_data.clear_subscriptions();
f(override);
f({override});
});
}
test("update_property", (override) => {
test("update_property", ({override}) => {
const sub = {...frontend};
stream_data.add_sub(sub);
@ -262,7 +262,7 @@ test("marked_subscribed (error)", () => {
blueslip.reset();
});
test("marked_subscribed (normal)", (override) => {
test("marked_subscribed (normal)", ({override}) => {
const sub = {...frontend};
stream_data.add_sub(sub);
override(stream_data, "subscribe_myself", noop);
@ -299,7 +299,7 @@ test("marked_subscribed (normal)", (override) => {
narrow_state.reset_current_filter();
});
test("marked_subscribed (color)", (override) => {
test("marked_subscribed (color)", ({override}) => {
override(stream_data, "subscribe_myself", noop);
override(message_util, "do_unread_count_updates", noop);
override(stream_list, "add_sidebar_row", noop);
@ -328,7 +328,7 @@ test("marked_subscribed (color)", (override) => {
}
});
test("marked_subscribed (emails)", (override) => {
test("marked_subscribed (emails)", ({override}) => {
const sub = {...frontend};
stream_data.add_sub(sub);
override(stream_color, "update_stream_color", noop);
@ -352,7 +352,7 @@ test("marked_subscribed (emails)", (override) => {
assert.deepEqual(sub, args.sub);
});
test("mark_unsubscribed (update_settings_for_unsubscribed)", (override) => {
test("mark_unsubscribed (update_settings_for_unsubscribed)", ({override}) => {
// Test unsubscribe
const sub = {...dev_help};
assert.ok(sub.subscribed);
@ -368,7 +368,7 @@ test("mark_unsubscribed (update_settings_for_unsubscribed)", (override) => {
assert.deepEqual(args.sub, sub);
});
test("mark_unsubscribed (render_title_area)", (override) => {
test("mark_unsubscribed (render_title_area)", ({override}) => {
const sub = {...frontend, subscribed: true};
stream_data.add_sub(sub);

View File

@ -50,7 +50,7 @@ const social = {
// We use this with override.
let num_unread_for_stream;
function create_devel_sidebar_row(override) {
function create_devel_sidebar_row({override}) {
const devel_count = $.create("devel-count");
const subscription_block = $.create("devel-block");
@ -69,7 +69,7 @@ function create_devel_sidebar_row(override) {
assert.equal(devel_count.text(), "42");
}
function create_social_sidebar_row(override) {
function create_social_sidebar_row({override}) {
const social_count = $.create("social-count");
const subscription_block = $.create("social-block");
@ -89,14 +89,14 @@ function create_social_sidebar_row(override) {
}
function test_ui(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
stream_data.clear_subscriptions();
stream_list.stream_sidebar.rows.clear();
f(override);
f({override});
});
}
test_ui("create_sidebar_row", (override) => {
test_ui("create_sidebar_row", ({override}) => {
// Make a couple calls to create_sidebar_row() and make sure they
// generate the right markup as well as play nice with get_stream_li().
page_params.demote_inactive_streams = 1;
@ -105,8 +105,8 @@ test_ui("create_sidebar_row", (override) => {
stream_data.add_sub(devel);
stream_data.add_sub(social);
create_devel_sidebar_row(override);
create_social_sidebar_row(override);
create_devel_sidebar_row({override});
create_social_sidebar_row({override});
const split = '<hr class="stream-split">';
const devel_sidebar = $("<devel sidebar row>");
@ -177,14 +177,14 @@ test_ui("create_sidebar_row", (override) => {
assert.ok(removed);
});
test_ui("pinned_streams_never_inactive", (override) => {
test_ui("pinned_streams_never_inactive", ({override}) => {
override(unread, "num_unread_for_stream", () => num_unread_for_stream);
stream_data.add_sub(devel);
stream_data.add_sub(social);
create_devel_sidebar_row(override);
create_social_sidebar_row(override);
create_devel_sidebar_row({override});
create_social_sidebar_row({override});
// non-pinned streams can be made inactive
const social_sidebar = $("<social sidebar row>");
@ -367,7 +367,7 @@ test_ui("zoom_in_and_zoom_out", () => {
assert.ok($("#streams_list").hasClass("zoom-out"));
});
test_ui("narrowing", (override) => {
test_ui("narrowing", ({override}) => {
initialize_stream_data();
topic_list.close = noop;
@ -421,7 +421,7 @@ test_ui("focusout_user_filter", () => {
click_handler(e);
});
test_ui("focus_user_filter", (override) => {
test_ui("focus_user_filter", ({override}) => {
override(scroll_util, "scroll_element_into_container", noop);
stream_list.set_event_handlers();
@ -435,7 +435,7 @@ test_ui("focus_user_filter", (override) => {
click_handler(e);
});
test_ui("sort_streams", (override) => {
test_ui("sort_streams", ({override}) => {
override(scroll_util, "scroll_element_into_container", noop);
// Get coverage on early-exit.
@ -487,7 +487,7 @@ test_ui("sort_streams", (override) => {
assert.ok(!stream_list.stream_sidebar.has_row_for(stream_id));
});
test_ui("separators_only_pinned_and_dormant", (override) => {
test_ui("separators_only_pinned_and_dormant", ({override}) => {
// Test only pinned and dormant streams
// Get coverage on early-exit.
@ -587,7 +587,7 @@ test_ui("separators_only_pinned", () => {
narrow_state.active = () => false;
test_ui("rename_stream", (override) => {
test_ui("rename_stream", ({override}) => {
initialize_stream_data();
const sub = stream_data.get_sub_by_name("devel");
@ -623,7 +623,7 @@ test_ui("rename_stream", (override) => {
assert.ok(count_updated);
});
test_ui("refresh_pin", (override) => {
test_ui("refresh_pin", ({override}) => {
initialize_stream_data();
override(scroll_util, "scroll_element_into_container", noop);
@ -660,7 +660,7 @@ test_ui("refresh_pin", (override) => {
assert.ok(scrolled);
});
test_ui("create_initial_sidebar_rows", (override) => {
test_ui("create_initial_sidebar_rows", ({override}) => {
initialize_stream_data();
const html_dict = new Map();

View File

@ -63,7 +63,7 @@ function clear_search_input() {
stream_list.clear_search({stopPropagation: noop});
}
run_test("basics", (override) => {
run_test("basics", ({override}) => {
let cursor_helper;
const input = $(".stream-list-filter");
const section = $(".stream_search_section");

View File

@ -45,9 +45,9 @@ function sort_groups(query) {
}
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
stream_data.clear_subscriptions();
f(override);
f({override});
});
}
@ -62,7 +62,7 @@ test("no_subscribed_streams", () => {
assert.equal(stream_sort.first_stream_id(), undefined);
});
test("basics", (override) => {
test("basics", ({override}) => {
stream_data.add_sub(scalene);
stream_data.add_sub(fast_tortoise);
stream_data.add_sub(pneumonia);

View File

@ -15,10 +15,10 @@ const stream_topic_history = zrequire("stream_topic_history");
const stream_topic_history_util = zrequire("stream_topic_history_util");
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
unread.declare_bankruptcy();
stream_topic_history.reset();
f(override);
f({override});
});
}
@ -338,7 +338,7 @@ test("server_history_end_to_end", () => {
assert.ok(on_success_called);
});
test("all_topics_in_cache", (override) => {
test("all_topics_in_cache", ({override}) => {
// Add a new stream with first_message_id set.
const general = {
name: "general",

View File

@ -67,7 +67,7 @@ run_test("make_server_callback", () => {
assert.ok(was_posted);
});
run_test("check sender", (override) => {
run_test("check sender", ({override}) => {
const message_id = 101;
const message = {

View File

@ -26,7 +26,7 @@ set_global("page_params", {});
const stream_data = zrequire("stream_data");
const subs = zrequire("subs");
run_test("redraw_left_panel", (override) => {
run_test("redraw_left_panel", ({override}) => {
// set-up sub rows stubs
const denmark = {
elem: "denmark",

View File

@ -16,7 +16,7 @@ const people = zrequire("people");
const pm_list = zrequire("pm_list");
const top_left_corner = zrequire("top_left_corner");
run_test("narrowing", (override) => {
run_test("narrowing", ({override}) => {
// activating narrow
let pm_expanded;

View File

@ -39,7 +39,7 @@ run_test("streams", () => {
assert_prev_stream("announce", "test here");
});
run_test("topics", (override) => {
run_test("topics", ({override}) => {
const streams = [1, 2, 3, 4];
const topics = new Map([
[1, ["read", "read", "1a", "1b", "read", "1c"]],
@ -119,7 +119,7 @@ run_test("topics", (override) => {
});
});
run_test("get_next_unread_pm_string", (override) => {
run_test("get_next_unread_pm_string", ({override}) => {
pm_conversations.recent.get_strings = () => ["1", "read", "2,3", "4", "unk"];
override(unread, "num_unread_for_person", (user_ids_string) => {

View File

@ -38,13 +38,13 @@ function get_list_info(zoomed) {
}
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
stream_topic_history.reset();
f(override);
f({override});
});
}
test("get_list_info w/real stream_topic_history", (override) => {
test("get_list_info w/real stream_topic_history", ({override}) => {
let list_info;
const empty_list_info = get_list_info();
@ -101,7 +101,7 @@ test("get_list_info w/real stream_topic_history", (override) => {
assert.equal(list_info.num_possible_topics, 2);
});
test("get_list_info unreads", (override) => {
test("get_list_info unreads", ({override}) => {
let list_info;
override(stream_topic_history, "get_recent_topic_names", () =>

View File

@ -98,7 +98,7 @@ run_test("transmit_message_ajax_reload_pending", () => {
assert.ok(reload_initiated);
});
run_test("reply_message_stream", (override) => {
run_test("reply_message_stream", ({override}) => {
const stream_message = {
type: "stream",
stream: "social",
@ -135,7 +135,7 @@ run_test("reply_message_stream", (override) => {
});
});
run_test("reply_message_private", (override) => {
run_test("reply_message_private", ({override}) => {
const fred = {
user_id: 3,
email: "fred@example.com",

View File

@ -99,7 +99,7 @@ stream_data.create_streams([
]);
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
pm_conversations.clear_for_testing();
recent_senders.clear_for_testing();
peer_data.clear_for_testing();
@ -109,11 +109,11 @@ function test(label, f) {
page_params.realm_email_address_visibility =
settings_config.email_address_visibility_values.admins_only.code;
f(override);
f({override});
});
}
test("sort_streams", (override) => {
test("sort_streams", ({override}) => {
let test_streams = [
{
stream_id: 101,
@ -602,7 +602,7 @@ test("highlight_with_escaping", () => {
assert.equal(result, expected);
});
test("render_person when emails hidden", (override) => {
test("render_person when emails hidden", ({override}) => {
// Test render_person with regular person, under hidden email visibility case
let rendered = false;
override(render_typeahead_list_item, "f", (args) => {
@ -615,7 +615,7 @@ test("render_person when emails hidden", (override) => {
assert.ok(rendered);
});
test("render_person", (override) => {
test("render_person", ({override}) => {
// Test render_person with regular person
page_params.is_admin = true;
let rendered = false;
@ -629,7 +629,7 @@ test("render_person", (override) => {
assert.ok(rendered);
});
test("render_person special_item_text", (override) => {
test("render_person special_item_text", ({override}) => {
let rendered = false;
// Test render_person with special_item_text person
@ -652,7 +652,7 @@ test("render_person special_item_text", (override) => {
assert.ok(rendered);
});
test("render_stream", (override) => {
test("render_stream", ({override}) => {
// Test render_stream with short description
let rendered = false;
const stream = {
@ -671,7 +671,7 @@ test("render_stream", (override) => {
assert.ok(rendered);
});
test("render_stream w/long description", (override) => {
test("render_stream w/long description", ({override}) => {
// Test render_stream with long description
let rendered = false;
const stream = {
@ -691,7 +691,7 @@ test("render_stream w/long description", (override) => {
assert.ok(rendered);
});
test("render_emoji", (override) => {
test("render_emoji", ({override}) => {
// Test render_emoji with normal emoji.
let expected_template_data = {
primary: "thumbs up",

View File

@ -9,10 +9,10 @@ const muting = zrequire("muting");
const typing_data = zrequire("typing_data");
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
typing_data.clear_for_testing();
muting.set_muted_users([]);
f(override);
f({override});
});
}

View File

@ -20,7 +20,7 @@ function returns_time(secs) {
};
}
run_test("basics", (override) => {
run_test("basics", ({override}) => {
typing_status.initialize_state();
// invalid conversation basically does nothing

View File

@ -55,10 +55,10 @@ function test_notifiable_count(home_unread_messages, expected_notifiable_count)
}
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
unread.declare_bankruptcy();
muting.set_muted_topics([]);
f(override);
f({override});
});
}
@ -242,7 +242,7 @@ test("muting", () => {
assert.equal(unread.num_unread_for_stream(unknown_stream_id), 0);
});
test("num_unread_for_topic", (override) => {
test("num_unread_for_topic", ({override}) => {
// Test the num_unread_for_topic() function using many
// messages.
const stream_id = 301;
@ -315,7 +315,7 @@ test("num_unread_for_topic", (override) => {
assert.deepEqual(msg_ids, []);
});
test("home_messages", (override) => {
test("home_messages", ({override}) => {
override(stream_data, "is_subscribed", () => true);
override(stream_data, "is_muted", () => false);

View File

@ -24,7 +24,7 @@ mock_cjs("jquery", $);
const helpers = zrequire("../js/billing/helpers");
zrequire("../js/billing/upgrade");
run_test("initialize", (override) => {
run_test("initialize", ({override}) => {
page_params.annual_price = 8000;
page_params.monthly_price = 800;
page_params.seat_count = 8;

View File

@ -39,13 +39,13 @@ const compose_actions = zrequire("compose_actions");
const upload = zrequire("upload");
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
page_params.max_file_upload_size_mib = 25;
f(override);
f({override});
});
}
test("feature_check", (override) => {
test("feature_check", ({override}) => {
const upload_button = $.create("upload-button-stub");
upload_button.addClass("notdisplayed");
upload.feature_check(upload_button);
@ -206,7 +206,7 @@ test("show_error_message", () => {
assert.equal($("#compose-error-msg").text(), "translated: An unknown error occurred.");
});
test("upload_files", (override) => {
test("upload_files", ({override}) => {
let uppy_cancel_all_called = false;
let files = [
{
@ -385,7 +385,7 @@ test("uppy_config", () => {
assert.equal(uppy_used_progressbar, true);
});
test("file_input", (override) => {
test("file_input", ({override}) => {
upload.setup_upload({mode: "compose"});
const change_handler = $("body").get_on_handler("change", "#compose .file_input");
@ -406,7 +406,7 @@ test("file_input", (override) => {
assert.ok(upload_files_called);
});
test("file_drop", (override) => {
test("file_drop", ({override}) => {
upload.setup_upload({mode: "compose"});
let prevent_default_counter = 0;
@ -444,7 +444,7 @@ test("file_drop", (override) => {
assert.equal(upload_files_called, true);
});
test("copy_paste", (override) => {
test("copy_paste", ({override}) => {
upload.setup_upload({mode: "compose"});
const paste_handler = $("#compose").get_on_handler("paste");
@ -483,7 +483,7 @@ test("copy_paste", (override) => {
assert.equal(upload_files_called, false);
});
test("uppy_events", (override) => {
test("uppy_events", ({override}) => {
const callbacks = {};
let uppy_cancel_all_called = false;
let state = {};

View File

@ -38,12 +38,12 @@ const isaac_item = {
let pill_widget = {};
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
people.init();
people.add_active_user(alice);
people.add_active_user(isaac);
pill_widget = {};
f(override);
f({override});
});
}

View File

@ -65,7 +65,7 @@ const all_user_ids = [alice.user_id, fred.user_id, jill.user_id, me.user_id];
const ordered_user_ids = [me.user_id, alice.user_id, fred.user_id, jill.user_id];
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
people.init();
people.add_active_user(alice);
people.add_active_user(fred);
@ -74,11 +74,11 @@ function test(label, f) {
people.initialize_current_user(me.user_id);
muting.set_muted_users([]);
activity.set_cursor_and_filter();
f(override);
f({override});
});
}
test("clear_search", (override) => {
test("clear_search", ({override}) => {
override(fake_buddy_list, "populate", (user_ids) => {
assert.deepEqual(user_ids, {keys: ordered_user_ids});
});
@ -94,7 +94,7 @@ test("clear_search", (override) => {
assert.ok($("#user_search_section").hasClass("notdisplayed"));
});
test("escape_search", (override) => {
test("escape_search", ({override}) => {
page_params.realm_presence_disabled = true;
override(resize, "resize_sidebars", () => {});
@ -107,7 +107,7 @@ test("escape_search", (override) => {
assert.ok($("#user_search_section").hasClass("notdisplayed"));
});
test("blur search right", (override) => {
test("blur search right", ({override}) => {
override(popovers, "show_userlist_sidebar", () => {});
override(popovers, "hide_all", () => {});
override(popovers, "hide_all_except_sidebars", () => {});
@ -124,7 +124,7 @@ test("blur search right", (override) => {
assert.equal($(".user-list-filter").is_focused(), true);
});
test("blur search left", (override) => {
test("blur search left", ({override}) => {
override(stream_popover, "show_streamlist_sidebar", () => {});
override(popovers, "hide_all", () => {});
override(popovers, "hide_all_except_sidebars", () => {});
@ -141,7 +141,7 @@ test("blur search left", (override) => {
assert.equal($(".user-list-filter").is_focused(), true);
});
test("filter_user_ids", (override) => {
test("filter_user_ids", ({override}) => {
const user_presence = {};
user_presence[alice.user_id] = "active";
user_presence[fred.user_id] = "active";
@ -195,7 +195,7 @@ test("filter_user_ids", (override) => {
test_filter("fr,al", [alice, fred]);
});
test("click on user header to toggle display", (override) => {
test("click on user header to toggle display", ({override}) => {
const user_filter = $(".user-list-filter");
override(popovers, "hide_all", () => {});

View File

@ -65,17 +65,17 @@ set_global("document", "document-stub");
const widgetize = zrequire("widgetize");
function test(label, f) {
run_test(label, (override) => {
run_test(label, ({override}) => {
events = [...sample_events];
widget_elem = undefined;
is_event_handled = false;
is_widget_activated = false;
widgetize.clear_for_testing();
f(override);
f({override});
});
}
test("activate", (override) => {
test("activate", ({override}) => {
// Both widgetize.activate and widgetize.handle_event are tested
// here to use the "caching" of widgets
const row = $.create("<stub message row>");

View File

@ -29,7 +29,9 @@ exports.run_test = (label, f, opts) => {
zpage_params.reset();
try {
namespace.with_overrides(f);
namespace.with_overrides((override) => {
f({override});
});
} catch (error) {
console.info("-".repeat(50));
console.info(`test failed: ${current_file_name} > ${label}`);