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.

frontend_tests: Use named functions to mock constructors.

Anders Kaseorg960174408f2c
diff --git a/frontend_tests/node_tests/list_render.js b/frontend_tests/node_tests/list_render.js
index 5d97dd98e9d..a183ed24df7 100644
--- a/frontend_tests/node_tests/list_render.js
+++ b/frontend_tests/node_tests/list_render.js
@@ -6,9 +6,10 @@ zrequire('list_render');
// that are either jQuery, Element, or just raw HTML
// strings. We initially test with raw strings.
set_global('jQuery', 'stub');
-set_global('Element', function () {
+function Element() {
return { };
-});
+}
+set_global('Element', Element);
// We only need very simple jQuery wrappers for when the
// "real" code wraps html or sets up click handlers.
diff --git a/frontend_tests/node_tests/markdown.js b/frontend_tests/node_tests/markdown.js
index 67c580c5a06..a763cc4c5be 100644
--- a/frontend_tests/node_tests/markdown.js
+++ b/frontend_tests/node_tests/markdown.js
@@ -44,9 +44,10 @@ set_global('page_params', {
translate_emoticons: false,
});
-set_global('Image', function () {
+function Image() {
return {};
-});
+}
+set_global('Image', Image);
emoji.initialize();
const doc = "";
diff --git a/frontend_tests/node_tests/message_fetch.js b/frontend_tests/node_tests/message_fetch.js
index 6d1a32ca58a..20ad12d0999 100644
--- a/frontend_tests/node_tests/message_fetch.js
+++ b/frontend_tests/node_tests/message_fetch.js
@@ -5,7 +5,10 @@ zrequire('message_fetch');
const noop = () => {};
-set_global('MessageListView', function () { return {}; });
+function MessageListView() {
+ return {};
+}
+set_global('MessageListView', MessageListView);
zrequire('FetchStatus', 'js/fetch_status');
zrequire('Filter', 'js/filter');
diff --git a/frontend_tests/node_tests/popovers.js b/frontend_tests/node_tests/popovers.js
index 02e7b24d59c..e9e12bbce55 100644
--- a/frontend_tests/node_tests/popovers.js
+++ b/frontend_tests/node_tests/popovers.js
@@ -42,9 +42,10 @@ set_global('stream_popover', {
set_global('stream_data', {});
-set_global('ClipboardJS', function (sel) {
+function ClipboardJS(sel) {
assert.equal(sel, '.copy_link');
-});
+}
+set_global('ClipboardJS', ClipboardJS);
const alice = {
@@ -95,9 +96,7 @@ function make_image_stubber() {
return image;
}
- set_global('Image', function () {
- return stub_image();
- });
+ set_global('Image', stub_image);
return {
get: (i) => images[i],
diff --git a/frontend_tests/node_tests/presence.js b/frontend_tests/node_tests/presence.js
index bb2e584e54b..c1d508b22b5 100644
--- a/frontend_tests/node_tests/presence.js
+++ b/frontend_tests/node_tests/presence.js
@@ -7,7 +7,10 @@ set_global('server_events', {});
set_global('reload_state', {
is_in_progress: return_false,
});
-set_global('XDate', function (ms) { return {seconds: ms}; });
+function XDate(ms) {
+ return {seconds: ms};
+}
+set_global('XDate', XDate);
const OFFLINE_THRESHOLD_SECS = 140;
diff --git a/frontend_tests/node_tests/settings_bots.js b/frontend_tests/node_tests/settings_bots.js
index cc6e9b6f792..1d8b83b3fbf 100644
--- a/frontend_tests/node_tests/settings_bots.js
+++ b/frontend_tests/node_tests/settings_bots.js
@@ -24,9 +24,10 @@ zrequire('bot_data');
zrequire('settings_bots');
zrequire('people');
-set_global('ClipboardJS', function (sel) {
+function ClipboardJS(sel) {
assert.equal(sel, '#copy_zuliprc');
-});
+}
+set_global('ClipboardJS', ClipboardJS);
bot_data.initialize(bot_data_params);