Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
node tests: Remove unnecessary zjquery stubs.
Steve Howell7bc48351144e
diff --git a/frontend_tests/node_tests/activity.js b/frontend_tests/node_tests/activity.jsindex a4936847b5e..f2cecec9fac 100644--- a/frontend_tests/node_tests/activity.js+++ b/frontend_tests/node_tests/activity.js@@ -51,15 +51,11 @@ const _pm_list = {const _popovers = {hide_all_except_sidebars() {},hide_all() {},- show_userlist_sidebar() {- $(".column-right").addClass("expanded");- },+ show_userlist_sidebar() {},};const _stream_popover = {- show_streamlist_sidebar() {- $(".column-left").addClass("expanded");- },+ show_streamlist_sidebar() {},};const _resize = {@@ -613,12 +609,10 @@ run_test("initiate_search", () => {$(".user-list-filter").trigger("blur");simulate_right_column_buddy_list();activity.initiate_search();- assert.equal($(".column-right").hasClass("expanded"), true);assert.equal($(".user-list-filter").is_focused(), true);simulate_left_column_buddy_list();activity.initiate_search();- assert.equal($(".column-left").hasClass("expanded"), true);assert.equal($(".user-list-filter").is_focused(), true);});diff --git a/frontend_tests/node_tests/buddy_list.js b/frontend_tests/node_tests/buddy_list.jsindex 1bf5ae7300f..fbf39c8163c 100644--- a/frontend_tests/node_tests/buddy_list.js+++ b/frontend_tests/node_tests/buddy_list.js@@ -87,8 +87,7 @@ run_test("basics", () => {});assert(appended);- const alice_li = $.create("alice-li-stub");- alice_li.length = 1;+ const alice_li = {length: 1};buddy_list.get_li_from_key = (opts) => {const key = opts.key;@@ -163,9 +162,7 @@ run_test("find_li w/force_render", () => {// key is not already rendered in DOM, then the// widget will call show_key to force-render it.const key = "999";- const stub_li = $.create("nada");-- stub_li.length = 0;+ const stub_li = {length: 0};buddy_list.get_li_from_key = (opts) => {assert.equal(opts.key, key);diff --git a/frontend_tests/node_tests/compose_pm_pill.js b/frontend_tests/node_tests/compose_pm_pill.jsindex a05df8ed5ce..0dd47675cca 100644--- a/frontend_tests/node_tests/compose_pm_pill.js+++ b/frontend_tests/node_tests/compose_pm_pill.js@@ -42,7 +42,7 @@ run_test("pills", () => {};const recipient_stub = $("#private_message_recipient");- const pill_container_stub = $('.pill-container[data-before="You and"]');+ const pill_container_stub = "pill-container";recipient_stub.set_parent(pill_container_stub);let create_item_handler;diff --git a/frontend_tests/node_tests/compose_ui.js b/frontend_tests/node_tests/compose_ui.jsindex 3cd0c0ddf4b..08c745c6c0e 100644--- a/frontend_tests/node_tests/compose_ui.js+++ b/frontend_tests/node_tests/compose_ui.js@@ -89,14 +89,10 @@ run_test("autosize_textarea", () => {}with_field(autosize, "update", fake_autosize_update, () => {- // Call autosize_textarea for the compose box- compose_ui.autosize_textarea($("#compose-textarea"));- assert.equal(textarea_autosized.textarea, $("#compose-textarea"));- assert(textarea_autosized.autosized);-// Call autosize_textarea with an argument- compose_ui.autosize_textarea($("#message_edit_content_65"));- assert.equal(textarea_autosized.textarea, $("#message_edit_content_65"));+ const container = "container-stub";+ compose_ui.autosize_textarea(container);+ assert.equal(textarea_autosized.textarea, container);assert(textarea_autosized.autosized);});});diff --git a/frontend_tests/node_tests/dispatch.js b/frontend_tests/node_tests/dispatch.jsindex fee444ae2f4..7756debb590 100644--- a/frontend_tests/node_tests/dispatch.js+++ b/frontend_tests/node_tests/dispatch.js@@ -203,7 +203,6 @@ run_test("hotspots", (override) => {run_test("invites_changed", (override) => {const event = event_fixtures.invites_changed;- $("#admin-invites-list").length = 1;with_stub((stub) => {override("settings_invites.set_up", stub.f);dispatch(event); // stub automatically checks if stub.f is called oncediff --git a/frontend_tests/node_tests/drafts.js b/frontend_tests/node_tests/drafts.jsindex 0874fd374dc..af6cd3969b2 100644--- a/frontend_tests/node_tests/drafts.js+++ b/frontend_tests/node_tests/drafts.js@@ -317,7 +317,6 @@ run_test("format_drafts", (override) => {override("drafts.open_overlay", noop);drafts.set_initial_element = noop;- $("#drafts_table .draft-row").length = 0;drafts.launch();timerender.render_now = stub_render_now;diff --git a/frontend_tests/node_tests/filter.js b/frontend_tests/node_tests/filter.jsindex 5a230b2e42e..57b1ef42750 100644--- a/frontend_tests/node_tests/filter.js+++ b/frontend_tests/node_tests/filter.js@@ -731,21 +731,19 @@ run_test("predicate_basics", () => {}const has_link = get_predicate([["has", "link"]]);- set_find_results_for_msg_content(img_msg, "a", [$("<a>")]);+ set_find_results_for_msg_content(img_msg, "a", ["stub"]);assert(has_link(img_msg));- set_find_results_for_msg_content(non_img_attachment_msg, "a", [$("<a>")]);+ set_find_results_for_msg_content(non_img_attachment_msg, "a", ["stub"]);assert(has_link(non_img_attachment_msg));- set_find_results_for_msg_content(link_msg, "a", [$("<a>")]);+ set_find_results_for_msg_content(link_msg, "a", ["stub"]);assert(has_link(link_msg));set_find_results_for_msg_content(no_has_filter_matching_msg, "a", false);assert(!has_link(no_has_filter_matching_msg));const has_attachment = get_predicate([["has", "attachment"]]);- set_find_results_for_msg_content(img_msg, "a[href^='/user_uploads']", [$("<a>")]);+ set_find_results_for_msg_content(img_msg, "a[href^='/user_uploads']", ["stub"]);assert(has_attachment(img_msg));- set_find_results_for_msg_content(non_img_attachment_msg, "a[href^='/user_uploads']", [- $("<a>"),- ]);+ set_find_results_for_msg_content(non_img_attachment_msg, "a[href^='/user_uploads']", ["stub"]);assert(has_attachment(non_img_attachment_msg));set_find_results_for_msg_content(link_msg, "a[href^='/user_uploads']", false);assert(!has_attachment(link_msg));@@ -753,7 +751,7 @@ run_test("predicate_basics", () => {assert(!has_attachment(no_has_filter_matching_msg));const has_image = get_predicate([["has", "image"]]);- set_find_results_for_msg_content(img_msg, ".message_inline_image", [$("<img>")]);+ set_find_results_for_msg_content(img_msg, ".message_inline_image", ["stub"]);assert(has_image(img_msg));set_find_results_for_msg_content(non_img_attachment_msg, ".message_inline_image", false);assert(!has_image(non_img_attachment_msg));