2022-08-19 21:36:33 +02:00
|
|
|
"use strict";
|
|
|
|
|
2024-11-12 03:59:37 +01:00
|
|
|
const compose_banner = require("../../src/compose_banner.ts");
|
2023-02-22 23:04:10 +01:00
|
|
|
|
2024-11-13 07:05:32 +01:00
|
|
|
const {noop} = require("./test.cjs");
|
|
|
|
const $ = require("./zjquery.cjs");
|
2022-08-19 21:36:33 +02:00
|
|
|
|
|
|
|
exports.mock_banners = () => {
|
|
|
|
// zjquery doesn't support `remove`, which is used when clearing the compose box.
|
|
|
|
// TODO: improve how we test this so that we don't have to mock things like this.
|
|
|
|
for (const classname of Object.values(compose_banner.CLASSNAMES)) {
|
2023-09-08 23:11:56 +02:00
|
|
|
$(
|
|
|
|
`#compose_banners .${classname
|
|
|
|
.split(" ")
|
|
|
|
.map((classname) => CSS.escape(classname))
|
|
|
|
.join(".")}`,
|
2023-12-14 23:51:33 +01:00
|
|
|
).remove = noop;
|
2022-08-19 21:36:33 +02:00
|
|
|
}
|
2023-12-14 23:51:33 +01:00
|
|
|
$("#compose_banners .warning").remove = noop;
|
|
|
|
$("#compose_banners .error").remove = noop;
|
|
|
|
$("#compose_banners .upload_banner").remove = noop;
|
2023-05-08 15:29:13 +02:00
|
|
|
|
|
|
|
const $stub = $.create("stub_to_remove");
|
|
|
|
const $cb = $("#compose_banners");
|
|
|
|
|
2023-12-14 23:51:33 +01:00
|
|
|
$stub.remove = noop;
|
2023-05-08 15:29:13 +02:00
|
|
|
$stub.length = 0;
|
|
|
|
|
|
|
|
$cb.closest = () => [];
|
|
|
|
$cb.set_find_results(".no_post_permissions", $stub);
|
|
|
|
$cb.set_find_results(".message_too_long", $stub);
|
|
|
|
$cb.set_find_results(".wildcards_not_allowed", $stub);
|
|
|
|
$cb.set_find_results(".wildcard_warning", $stub);
|
|
|
|
$cb.set_find_results(".topic_missing", $stub);
|
|
|
|
$cb.set_find_results(".missing_stream", $stub);
|
|
|
|
$cb.set_find_results(".zephyr_not_running", $stub);
|
|
|
|
$cb.set_find_results(".deactivated_user", $stub);
|
|
|
|
$cb.set_find_results(".missing_private_message_recipient", $stub);
|
|
|
|
$cb.set_find_results(".subscription_error", $stub);
|
|
|
|
$cb.set_find_results(".generic_compose_error", $stub);
|
2022-08-19 21:36:33 +02:00
|
|
|
};
|