diff --git a/test/unit-tests/HtmlUtils-test.tsx b/test/unit-tests/HtmlUtils-test.tsx index ef458d4330..1dbd9cabda 100644 --- a/test/unit-tests/HtmlUtils-test.tsx +++ b/test/unit-tests/HtmlUtils-test.tsx @@ -7,7 +7,6 @@ Please see LICENSE files in the repository root for full details. */ import React from "react"; -import { mocked } from "jest-mock"; import { render, screen } from "jest-matrix-react"; import parse from "html-react-parser"; @@ -15,16 +14,13 @@ import { bodyToHtml, bodyToNode, formatEmojis, topicToHtml } from "../../src/Htm import SettingsStore from "../../src/settings/SettingsStore"; import { getMockClientWithEventEmitter } from "../test-utils"; import { SettingLevel } from "../../src/settings/SettingLevel"; - -jest.mock("../../src/settings/SettingsStore"); - -const enableHtmlTopicFeature = () => { - mocked(SettingsStore).getValue.mockImplementation((arg): any => { - return arg === "feature_html_topic"; - }); -}; +import SdkConfig from "../../src/SdkConfig"; describe("topicToHtml", () => { + afterEach(() => { + SettingsStore.reset(); + }); + function getContent() { return screen.getByRole("contentinfo").children[0].innerHTML; } @@ -40,19 +36,19 @@ describe("topicToHtml", () => { }); it("converts literal HTML topic to HTML", async () => { - enableHtmlTopicFeature(); + SettingsStore.setValue("feature_html_topic", null, SettingLevel.DEVICE, true); render(
{topicToHtml("pizza", undefined, null, false)}
); expect(getContent()).toEqual("<b>pizza</b>"); }); it("converts true HTML topic to HTML", async () => { - enableHtmlTopicFeature(); + SettingsStore.setValue("feature_html_topic", null, SettingLevel.DEVICE, true); render(
{topicToHtml("**pizza**", "pizza", null, false)}
); expect(getContent()).toEqual("pizza"); }); it("converts true HTML topic with emoji to HTML", async () => { - enableHtmlTopicFeature(); + SettingsStore.setValue("feature_html_topic", null, SettingLevel.DEVICE, true); render(
{topicToHtml("**pizza** 🍕", "pizza 🍕", null, false)}
); expect(getContent()).toEqual('pizza 🍕'); }); @@ -109,11 +105,12 @@ describe("bodyToHtml", () => { describe("feature_latex_maths", () => { beforeEach(() => { - SettingsStore.setValue("feature_latex_maths", null, SettingLevel.ACCOUNT, true); + SettingsStore.setValue("feature_latex_maths", null, SettingLevel.DEVICE, true); }); afterEach(() => { SettingsStore.reset(); + SdkConfig.reset(); }); it("should render inline katex", () => { diff --git a/test/unit-tests/components/structures/MatrixChat-test.tsx b/test/unit-tests/components/structures/MatrixChat-test.tsx index 11887177b6..47712248de 100644 --- a/test/unit-tests/components/structures/MatrixChat-test.tsx +++ b/test/unit-tests/components/structures/MatrixChat-test.tsx @@ -486,7 +486,7 @@ describe("", () => { afterEach(() => { SettingsStore.reset(); - }) + }); it("should persist login credentials", async () => { getComponent({ realQueryParams }); diff --git a/test/unit-tests/components/structures/TimelinePanel-test.tsx b/test/unit-tests/components/structures/TimelinePanel-test.tsx index 39dbcf64b5..87c788d9f9 100644 --- a/test/unit-tests/components/structures/TimelinePanel-test.tsx +++ b/test/unit-tests/components/structures/TimelinePanel-test.tsx @@ -313,8 +313,7 @@ describe("TimelinePanel", () => { describe("and sending receipts is disabled", () => { beforeEach(async () => { // Ensure this setting is supported, otherwise it will use the default value. - client.isVersionSupported.mockResolvedValue(true); - client.doesServerSupportUnstableFeature.mockResolvedValue(true); + client.isVersionSupported.mockImplementation(async (v) => v === "v1.4"); MatrixClientBackedController.matrixClient = client; SettingsStore.setValue("sendReadReceipts", null, SettingLevel.DEVICE, false); }); diff --git a/test/unit-tests/components/views/rooms/RoomHeader/RoomHeader-test.tsx b/test/unit-tests/components/views/rooms/RoomHeader/RoomHeader-test.tsx index d591337622..3cef5978f4 100644 --- a/test/unit-tests/components/views/rooms/RoomHeader/RoomHeader-test.tsx +++ b/test/unit-tests/components/views/rooms/RoomHeader/RoomHeader-test.tsx @@ -360,7 +360,7 @@ describe("RoomHeader", () => { SdkConfig.put({ features: { feature_group_calls: true, - } + }, }); }); @@ -422,7 +422,7 @@ describe("RoomHeader", () => { }, features: { feature_group_calls: false, - } + }, }); // allow calls jest.spyOn(room.currentState, "mayClientSendStateEvent").mockReturnValue(true); @@ -475,9 +475,9 @@ describe("RoomHeader", () => { jest.spyOn(room, "canInvite").mockReturnValue(false); SdkConfig.add({ element_call: { - guest_spa_url: "https://guest_spa_url.com" - } - }) + guest_spa_url: "https://guest_spa_url.com", + }, + }); const { container: containerNoInviteNotPublicCanUpgradeAccess } = render( , getWrapper(), @@ -696,7 +696,7 @@ describe("RoomHeader", () => { afterEach(() => { SdkConfig.reset(); - }) + }); it.each([ [ShieldUtils.E2EStatus.Verified, "Verified"], @@ -712,8 +712,8 @@ describe("RoomHeader", () => { it("does not show the face pile for DMs", () => { SdkConfig.put({ features: { - feature_notifications: false - } + feature_notifications: false, + }, }); const { asFragment } = render(, getWrapper()); diff --git a/test/unit-tests/components/views/settings/tabs/user/__snapshots__/PreferencesUserSettingsTab-test.tsx.snap b/test/unit-tests/components/views/settings/tabs/user/__snapshots__/PreferencesUserSettingsTab-test.tsx.snap index 5209a41fa0..d1226a5e3b 100644 --- a/test/unit-tests/components/views/settings/tabs/user/__snapshots__/PreferencesUserSettingsTab-test.tsx.snap +++ b/test/unit-tests/components/views/settings/tabs/user/__snapshots__/PreferencesUserSettingsTab-test.tsx.snap @@ -1187,7 +1187,9 @@ exports[`PreferencesUserSettingsTab should render 1`] = `