mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 04:23:46 +00:00
ES and TypeScript modules are strict by default and don’t need this directive. ESLint will remind us to add it to new CommonJS files and remove it from ES and TypeScript modules. Signed-off-by: Anders Kaseorg <anders@zulip.com>
35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
"use strict";
|
|
|
|
set_global("$", global.make_zjquery());
|
|
zrequire("spoilers");
|
|
|
|
// This function is taken from rendered_markdown.js and slightly modified.
|
|
const $array = (array) => {
|
|
const each = (func) => {
|
|
array.forEach((elem, index) => {
|
|
func.call(this, index, elem);
|
|
});
|
|
};
|
|
return {each};
|
|
};
|
|
|
|
const get_spoiler_elem = (title) => {
|
|
const block = $.create(`block-${title}`);
|
|
const header = $.create(`header-${title}`);
|
|
const content = $.create(`content-${title}`);
|
|
header.text(title);
|
|
block.set_find_results(".spoiler-header", header);
|
|
block.set_find_results(".spoiler-content", content);
|
|
return block;
|
|
};
|
|
|
|
run_test("hide spoilers in notifications", () => {
|
|
const root = $.create("root element");
|
|
const spoiler_1 = get_spoiler_elem("this is the title");
|
|
const spoiler_2 = get_spoiler_elem("");
|
|
root.set_find_results(".spoiler-block", $array([spoiler_1, spoiler_2]));
|
|
spoilers.hide_spoilers_in_notification(root);
|
|
assert.equal(spoiler_1.find(".spoiler-header").text(), "this is the title (…)");
|
|
assert.equal(spoiler_2.find(".spoiler-header").text(), "(…)");
|
|
});
|