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: Refactor generic_event to wrap on.

Anders Kaseorgded548ad167a
diff --git a/frontend_tests/node_tests/activity.js b/frontend_tests/node_tests/activity.js
index 2d3595337b2..dd086358174 100644
--- a/frontend_tests/node_tests/activity.js
+++ b/frontend_tests/node_tests/activity.js
@@ -700,6 +700,7 @@ run_test("initialize", () => {
activity.client_is_active = false;
+ $(window).off("focus");
activity.initialize();
$(window).trigger("focus");
clear();
@@ -719,6 +720,7 @@ run_test("initialize", () => {
};
global.setInterval = (func) => func();
+ $(window).off("focus");
activity.initialize();
assert($("#zephyr-mirror-error").hasClass("show"));
diff --git a/frontend_tests/node_tests/compose.js b/frontend_tests/node_tests/compose.js
index ded4c2e1281..a11abed9eae 100644
--- a/frontend_tests/node_tests/compose.js
+++ b/frontend_tests/node_tests/compose.js
@@ -748,6 +748,7 @@ run_test("send_message", () => {
$("#compose-send-status").show();
$("#compose-send-button").attr("disabled", "disabled");
$("#sending-indicator").show();
+ $("#compose-textarea").off("select");
$("#compose-textarea").select(noop);
echo_error_msg_checked = false;
echo.try_deliver_locally = function () {
@@ -822,6 +823,7 @@ run_test("finish", () => {
$("#compose-send-button").prop("disabled", false);
$("#compose-send-button").focus();
$("#sending-indicator").hide();
+ $("#compose-textarea").off("select");
$("#compose-textarea").select(noop);
$("#compose-textarea").val("");
const res = compose.finish();
diff --git a/frontend_tests/node_tests/composebox_typeahead.js b/frontend_tests/node_tests/composebox_typeahead.js
index 1eb17d01efd..0c8f3682b7a 100644
--- a/frontend_tests/node_tests/composebox_typeahead.js
+++ b/frontend_tests/node_tests/composebox_typeahead.js
@@ -1097,6 +1097,14 @@ run_test("initialize", () => {
return true;
};
$("#enter_sends").click();
+
+ $("#stream_message_recipient_stream").off("focus");
+ $("#stream_message_recipient_topic").off("focus");
+ $("#private_message_recipient").off("focus");
+ $("form#send_message_form").off("keydown");
+ $("form#send_message_form").off("keyup");
+ $("#enter_sends").off("click");
+ $("#private_message_recipient").off("blur");
ct.initialize();
// Now let's make sure that all the stub functions have been called
diff --git a/frontend_tests/zjsunit/zjquery.js b/frontend_tests/zjsunit/zjquery.js
index a0f828da114..551b6504457 100644
--- a/frontend_tests/zjsunit/zjquery.js
+++ b/frontend_tests/zjsunit/zjquery.js
@@ -130,7 +130,7 @@ exports.make_event_store = (selector) => {
generic_event($element, event_name, arg) {
if (typeof arg === "function") {
- on_functions.set(event_name, arg);
+ self.on(event_name, arg);
} else {
self.trigger($element, event_name, arg);
}