1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-08-06 10:22:45 +03:00
This commit is contained in:
David Baker
2024-07-03 17:34:05 +01:00
parent 4165a36212
commit 2c30f48c38

View File

@@ -15,7 +15,8 @@ limitations under the License.
*/ */
import React from "react"; import React from "react";
import { fireEvent, render, RenderResult, waitFor } from "@testing-library/react"; import { fireEvent, render, RenderResult, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import PreferencesUserSettingsTab from "../../../../../../src/components/views/settings/tabs/user/PreferencesUserSettingsTab"; import PreferencesUserSettingsTab from "../../../../../../src/components/views/settings/tabs/user/PreferencesUserSettingsTab";
import { MatrixClientPeg } from "../../../../../../src/MatrixClientPeg"; import { MatrixClientPeg } from "../../../../../../src/MatrixClientPeg";
@@ -23,6 +24,7 @@ import { mockPlatformPeg, stubClient } from "../../../../../test-utils";
import SettingsStore from "../../../../../../src/settings/SettingsStore"; import SettingsStore from "../../../../../../src/settings/SettingsStore";
import { SettingLevel } from "../../../../../../src/settings/SettingLevel"; import { SettingLevel } from "../../../../../../src/settings/SettingLevel";
import MatrixClientBackedController from "../../../../../../src/settings/controllers/MatrixClientBackedController"; import MatrixClientBackedController from "../../../../../../src/settings/controllers/MatrixClientBackedController";
import PlatformPeg from "../../../../../../src/PlatformPeg";
describe("PreferencesUserSettingsTab", () => { describe("PreferencesUserSettingsTab", () => {
beforeEach(() => { beforeEach(() => {
@@ -38,6 +40,21 @@ describe("PreferencesUserSettingsTab", () => {
expect(asFragment()).toMatchSnapshot(); expect(asFragment()).toMatchSnapshot();
}); });
it("should reload when changing language", async () => {
const reloadStub = jest.fn();
PlatformPeg.get()!.reload = reloadStub;
renderTab();
const languageDropdown = await screen.findByRole("button", { name: "Language Dropdown" });
expect(languageDropdown).toBeInTheDocument();
await userEvent.click(languageDropdown);
const germanOption = await screen.findByText("Deutsch");
await userEvent.click(germanOption);
expect(reloadStub).toHaveBeenCalled();
});
describe("send read receipts", () => { describe("send read receipts", () => {
beforeEach(() => { beforeEach(() => {
stubClient(); stubClient();