Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

zjquery: Move detach method to FakeElement.

Anders Kaseorg3cb35c6d01f2
diff --git a/web/tests/lib/zjquery_element.cjs b/web/tests/lib/zjquery_element.cjs
index de996c1dfc4..ca5b8e778fc 100644
--- a/web/tests/lib/zjquery_element.cjs
+++ b/web/tests/lib/zjquery_element.cjs
@@ -243,6 +243,12 @@ exports.FakeJQuery = function (selector, opts) {
}
return this;
},
+ detach() {
+ for (const element of this) {
+ element.remove();
+ }
+ return this;
+ },
each(callback) {
for (const [index, element] of [...this].entries()) {
callback.call(element, index, element);
diff --git a/web/tests/stream_settings_ui.test.cjs b/web/tests/stream_settings_ui.test.cjs
index f2147c2c405..7ebb1db9eb9 100644
--- a/web/tests/stream_settings_ui.test.cjs
+++ b/web/tests/stream_settings_ui.test.cjs
@@ -246,9 +246,7 @@ run_test("redraw_left_panel", ({override, mock_template}) => {
sub_stubs.push(sub_row);
$(sub_row).attr("data-stream-id", data.stream_id);
- $(sub_row).detach = function () {
- return this;
- };
+ $(sub_row)[0].remove = () => {};
}
$.set_results("#channels_overlay_container .stream-row", sub_stubs);