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.

tests: Set jQuery object as find results.

Anders Kaseorg87eafc74d24f
diff --git a/web/tests/input_pill.test.cjs b/web/tests/input_pill.test.cjs
index 90449b1ad6f..cee65337393 100644
--- a/web/tests/input_pill.test.cjs
+++ b/web/tests/input_pill.test.cjs
@@ -210,10 +210,9 @@ run_test("arrows on pills", ({mock_template}) => {
const $prev_pill_stub = $.create("prev-pill-stub");
const $next_pill_stub = $.create("next-pill-stub");
- const $pill_stub = {
- prev: () => $prev_pill_stub,
- next: () => $next_pill_stub,
- };
+ const $pill_stub = $.create("pill-stub");
+ $pill_stub.prev = () => $prev_pill_stub;
+ $pill_stub.next = () => $next_pill_stub;
$container.set_find_results(".pill:focus", $pill_stub);
@@ -244,15 +243,15 @@ run_test("left arrow on input", ({mock_template}) => {
let last_pill_focused = false;
- $container.set_find_results(".pill", {
- last: () => ({
- trigger(type) {
- if (type === "focus") {
- last_pill_focused = true;
- }
- },
- }),
+ const $pill_stub = $.create("pill-stub");
+ $pill_stub.last = () => ({
+ trigger(type) {
+ if (type === "focus") {
+ last_pill_focused = true;
+ }
+ },
});
+ $container.set_find_results(".pill", $pill_stub);
key_handler({
key: "ArrowLeft",
diff --git a/web/tests/notifications.test.cjs b/web/tests/notifications.test.cjs
index e27255dcc2a..50195a91715 100644
--- a/web/tests/notifications.test.cjs
+++ b/web/tests/notifications.test.cjs
@@ -352,8 +352,11 @@ test("message_is_notifiable", ({override}) => {
});
test("basic_notifications", () => {
- $("<div>").set_find_results(".emoji", {text: () => ({contents: () => ({unwrap() {}})})});
- $("<div>").set_find_results("span.katex", {each() {}});
+ const $emoji_stub = $.create("emoji-stub");
+ $emoji_stub.contents = () => ({unwrap() {}});
+ const $katex_stub = $.set_results("katex-stub", []);
+ $("<div>").set_find_results(".emoji", $emoji_stub);
+ $("<div>").set_find_results("span.katex", $katex_stub);
$("<div>").children = () => [];
let n; // Object for storing all notification data for assertions.
diff --git a/web/tests/rendered_markdown.test.cjs b/web/tests/rendered_markdown.test.cjs
index adc71c114f3..177945f185a 100644
--- a/web/tests/rendered_markdown.test.cjs
+++ b/web/tests/rendered_markdown.test.cjs
@@ -197,11 +197,11 @@ run_test("message_inline_video", () => {
const $elem = $.create("message_inline_video");
let load_called = false;
- $elem.load = () => {
+ $elem[0].load = () => {
load_called = true;
};
- $content.set_find_results(".message_inline_video video", $array([$elem]));
+ $content.set_find_results(".message_inline_video video", $array([$elem[0]]));
window.GestureEvent = true;
rm.update_elements($content);
assert.equal(load_called, true);