Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
zjquery: Move replaceWith accessor to FakeElement.
Anders Kaseorgefbab2f065c2
diff --git a/web/tests/input_pill.test.cjs b/web/tests/input_pill.test.cjsindex 9b99ed7fa81..54ecbb64bd4 100644--- a/web/tests/input_pill.test.cjs+++ b/web/tests/input_pill.test.cjs@@ -723,9 +723,9 @@ run_test("updatePill", ({mock_template}) => {};let element_replaced = false;- blue_pill.$element.replaceWith = ($new_elem) => {+ blue_pill.$element[0].replaceWith = (new_element) => {element_replaced = true;- assert.equal($new_elem.html(), pill_html("DARK BLUE"));+ assert.equal(new_element.innerHTML, pill_html("DARK BLUE"));};widget.updatePill(blue_pill.$element[0], updated_blue_data);diff --git a/web/tests/lib/zjquery_element.cjs b/web/tests/lib/zjquery_element.cjsindex 62fabbb1149..c7528feec40 100644--- a/web/tests/lib/zjquery_element.cjs+++ b/web/tests/lib/zjquery_element.cjs@@ -669,6 +669,11 @@ exports.FakeJQuery = function (selector, opts) {}return this;},+ replaceWith(...args) {+ assert.equal(this.length, 1);+ this[0].replaceWith(...dom_args(args));+ return this;+ },set_children_results(selector, $result) {assert.equal(this.length, 1);fake_element_state.get(this[0]).jquery_children_results.set(selector, $result);diff --git a/web/tests/rendered_markdown.test.cjs b/web/tests/rendered_markdown.test.cjsindex 13796d44e80..9bbe7082b8c 100644--- a/web/tests/rendered_markdown.test.cjs+++ b/web/tests/rendered_markdown.test.cjs@@ -417,7 +417,7 @@ run_test("stream-links", ({mock_template}) => {"href",`/#narrow/channel/${stream.stream_id}-random/topic/topic.20name.20.3E.20still.20the.20topic.20name`,);- $stream_topic.replaceWith = noop;+ $stream_topic[0].replaceWith = noop;$stream_topic.addClass("stream-topic");$stream_topic.text("#random > topic name > still the topic name");@@ -456,7 +456,7 @@ run_test("topic-link (empty string topic)", ({mock_template}) => {const $channel_topic = $.create("a.stream-topic(empty-string-topic)");$channel_topic.set_find_results(".highlight", false);$channel_topic.attr("href", `/#narrow/channel/${stream.stream_id}-random/topic/`);- $channel_topic.replaceWith = noop;+ $channel_topic[0].replaceWith = noop;$channel_topic.addClass("stream-topic");$channel_topic.html(`#random > <em>${REALM_EMPTY_TOPIC_DISPLAY_NAME}</em>`);$content.set_find_results("a.stream-topic, a.message-link", $array([$channel_topic]));@@ -494,7 +494,7 @@ run_test("message-links", ({mock_template}) => {"href",`/#narrow/channel/${stream.stream_id}-${stream.name}/topic//near/123`,);- $channel_topic_message.replaceWith = noop;+ $channel_topic_message[0].replaceWith = noop;$channel_topic_message.addClass("message-link");$channel_topic_message.html(`#${stream.name} > <em>${REALM_EMPTY_TOPIC_DISPLAY_NAME}</em> @ 💬`,@@ -539,7 +539,7 @@ run_test("audio", ({mock_template}) => {const $content = get_content_element();const $audio = $.create("audio");- $audio.replaceWith = noop;+ $audio[0].replaceWith = noop;$audio.attr("src", audio_src);$audio.attr("title", audio_title);