tests: Avoid override_rewire of imports.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2024-11-08 01:26:04 -08:00 committed by Tim Abbott
parent c57f12a792
commit a37aab19ed
2 changed files with 7 additions and 6 deletions

View File

@ -2,6 +2,8 @@
const assert = require("node:assert/strict"); const assert = require("node:assert/strict");
const katex = require("katex");
const markdown_test_cases = require("../../zerver/tests/fixtures/markdown_test_cases"); const markdown_test_cases = require("../../zerver/tests/fixtures/markdown_test_cases");
const markdown_assert = require("./lib/markdown_assert"); const markdown_assert = require("./lib/markdown_assert");
@ -1047,12 +1049,10 @@ test("missing unicode emojis", ({override}) => {
assert.equal(message.content, "<p>\u{1F6B2}</p>"); assert.equal(message.content, "<p>\u{1F6B2}</p>");
}); });
test("katex_throws_unexpected_exceptions", ({override_rewire}) => { test("katex_throws_unexpected_exceptions", ({override}) => {
const message = {raw_content: "$$a$$"}; const message = {raw_content: "$$a$$"};
override_rewire(markdown, "katex", { override(katex, "renderToString", () => {
renderToString() {
throw new Error("some-exception"); throw new Error("some-exception");
},
}); });
assert.throws(() => markdown.render(message.raw_content), { assert.throws(() => markdown.render(message.raw_content), {
name: "Error", name: "Error",

View File

@ -10,6 +10,7 @@ const stream_topic_history = mock_esm("../src/stream_topic_history");
const settings_config = zrequire("settings_config"); const settings_config = zrequire("settings_config");
const pm_conversations = zrequire("pm_conversations"); const pm_conversations = zrequire("pm_conversations");
const bootstrap_typeahead = zrequire("bootstrap_typeahead");
const recent_senders = zrequire("recent_senders"); const recent_senders = zrequire("recent_senders");
const peer_data = zrequire("peer_data"); const peer_data = zrequire("peer_data");
const people = zrequire("people"); const people = zrequire("people");
@ -1053,7 +1054,7 @@ test("sort_group_setting_options", ({override_rewire}) => {
b_user_3.full_name, 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), [ assert.deepEqual(get_group_setting_typeahead_result("Bo", second_bob_group), [
bob_system_group.name, bob_system_group.name,
bob_group.name, bob_group.name,