From a37aab19ed0cb1b1b43608190c31f02c4a8a8984 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Fri, 8 Nov 2024 01:26:04 -0800 Subject: [PATCH] tests: Avoid override_rewire of imports. Signed-off-by: Anders Kaseorg --- web/tests/markdown.test.js | 10 +++++----- web/tests/typeahead_helper.test.js | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/web/tests/markdown.test.js b/web/tests/markdown.test.js index 1f5a87dd2c..b6f29c42d1 100644 --- a/web/tests/markdown.test.js +++ b/web/tests/markdown.test.js @@ -2,6 +2,8 @@ const assert = require("node:assert/strict"); +const katex = require("katex"); + const markdown_test_cases = require("../../zerver/tests/fixtures/markdown_test_cases"); const markdown_assert = require("./lib/markdown_assert"); @@ -1047,12 +1049,10 @@ test("missing unicode emojis", ({override}) => { assert.equal(message.content, "

\u{1F6B2}

"); }); -test("katex_throws_unexpected_exceptions", ({override_rewire}) => { +test("katex_throws_unexpected_exceptions", ({override}) => { const message = {raw_content: "$$a$$"}; - override_rewire(markdown, "katex", { - renderToString() { - throw new Error("some-exception"); - }, + override(katex, "renderToString", () => { + throw new Error("some-exception"); }); assert.throws(() => markdown.render(message.raw_content), { name: "Error", diff --git a/web/tests/typeahead_helper.test.js b/web/tests/typeahead_helper.test.js index 72c6a5556d..4b315e9453 100644 --- a/web/tests/typeahead_helper.test.js +++ b/web/tests/typeahead_helper.test.js @@ -10,6 +10,7 @@ const stream_topic_history = mock_esm("../src/stream_topic_history"); const settings_config = zrequire("settings_config"); const pm_conversations = zrequire("pm_conversations"); +const bootstrap_typeahead = zrequire("bootstrap_typeahead"); const recent_senders = zrequire("recent_senders"); const peer_data = zrequire("peer_data"); const people = zrequire("people"); @@ -1053,7 +1054,7 @@ test("sort_group_setting_options", ({override_rewire}) => { b_user_3.full_name, ]); - override_rewire(th, "MAX_ITEMS", 6); + override_rewire(bootstrap_typeahead, "MAX_ITEMS", 6); assert.deepEqual(get_group_setting_typeahead_result("Bo", second_bob_group), [ bob_system_group.name, bob_group.name,