frontend_tests: Use named functions to mock constructors.

This will stop ESLint from replacing them with arrow functions, which
cannot be constructors.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2020-07-01 16:55:18 -07:00 committed by Tim Abbott
parent 615b7fcc2c
commit 960174408f
6 changed files with 21 additions and 13 deletions

View File

@ -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.

View File

@ -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 = "";

View File

@ -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');

View File

@ -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 = {
email: 'alice@example.com',
@ -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],

View File

@ -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;

View File

@ -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);