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.

channel: Add while_reloading test cases for 100% coverage.

YashRE422b03a74d975c
diff --git a/frontend_tests/node_tests/channel.js b/frontend_tests/node_tests/channel.js
index 4bdff4d406d..6b9888f0fe7 100644
--- a/frontend_tests/node_tests/channel.js
+++ b/frontend_tests/node_tests/channel.js
@@ -306,3 +306,37 @@ run_test("xhr_error_message", () => {
msg = "some message";
assert.equal(channel.xhr_error_message(msg, xhr), "some message: file not found");
});
+
+run_test("while_reloading", () => {
+ reload_state.set_state_to_in_progress();
+
+ assert.equal(channel.get({ignore_reload: false}), undefined);
+
+ let orig_success_called = false;
+ let orig_error_called = false;
+
+ test_with_mock_ajax({
+ run_code() {
+ channel.del({
+ url: "/json/endpoint",
+ ignore_reload: true,
+ success() {
+ orig_success_called = true;
+ },
+ error() {
+ orig_error_called = true;
+ },
+ });
+ },
+
+ check_ajax_options(options) {
+ blueslip.expect("log", "Ignoring DELETE /json/endpoint response while reloading");
+ options.simulate_success();
+ assert(!orig_success_called);
+
+ blueslip.expect("log", "Ignoring DELETE /json/endpoint error response while reloading");
+ options.simulate_error();
+ assert(!orig_error_called);
+ },
+ });
+});
diff --git a/tools/test-js-with-node b/tools/test-js-with-node
index 89d2f6d4b46..8a657fbb837 100755
--- a/tools/test-js-with-node
+++ b/tools/test-js-with-node
@@ -42,7 +42,6 @@ EXEMPT_FILES = {
"static/js/billing/helpers.js",
"static/js/blueslip.js",
"static/js/blueslip_stacktrace.ts",
- "static/js/channel.js",
"static/js/click_handlers.js",
"static/js/compose_actions.js",
"static/js/composebox_typeahead.js",