Refactor languageHandler to avoid import cycles (#33948)
* Refactor languageHandler to avoid import cycles Also move its tests to vitest * Small refactor * Iterate * Iterate
This commit is contained in:
@@ -36,7 +36,7 @@ import {
|
||||
import MatrixClientContext from "../../../../../src/contexts/MatrixClientContext";
|
||||
import { type RoomPermalinkCreator } from "../../../../../src/utils/permalinks/Permalinks";
|
||||
import { type MediaEventHelper } from "../../../../../src/utils/MediaEventHelper";
|
||||
import * as languageHandler from "../../../../../src/languageHandler";
|
||||
import * as languageSettings from "../../../../../src/i18n/settings";
|
||||
|
||||
const CHECKED = "mx_PollOption_checked";
|
||||
const userId = "@me:example.com";
|
||||
@@ -55,7 +55,7 @@ describe("MPollBody", () => {
|
||||
|
||||
mockClient.getRoom.mockReturnValue(null);
|
||||
mockClient.relations.mockResolvedValue({ events: [] });
|
||||
jest.spyOn(languageHandler, "getUserLanguage").mockReturnValue("en-GB");
|
||||
jest.spyOn(languageSettings, "getUserLanguage").mockReturnValue("en-GB");
|
||||
});
|
||||
|
||||
it("finds no votes if there are none", () => {
|
||||
|
||||
@@ -11,6 +11,7 @@ import { type MatrixClient, type MatrixEvent, PushRuleKind, type Room } from "ma
|
||||
import { mocked, type MockedObject } from "jest-mock-vitest-adapter";
|
||||
import { act, render, waitFor } from "jest-matrix-react";
|
||||
import { PushProcessor } from "matrix-js-sdk/src/pushprocessor";
|
||||
import { setMissingEntryGenerator } from "@element-hq/web-shared-components";
|
||||
|
||||
import {
|
||||
getMockClientWithEventEmitter,
|
||||
@@ -19,7 +20,6 @@ import {
|
||||
mkStubRoom,
|
||||
mockClientPushProcessor,
|
||||
} from "../../../../test-utils";
|
||||
import * as languageHandler from "../../../../../src/languageHandler";
|
||||
import DMRoomMap from "../../../../../src/utils/DMRoomMap";
|
||||
import { TextualBodyFactory as TextualBody } from "../../../../../src/components/views/messages/TextualBodyFactory";
|
||||
import MatrixClientContext from "../../../../../src/contexts/MatrixClientContext";
|
||||
@@ -470,7 +470,7 @@ describe("<TextualBody />", () => {
|
||||
let matrixClient: MatrixClient;
|
||||
|
||||
beforeEach(() => {
|
||||
languageHandler.setMissingEntryGenerator((key) => key.split("|", 2)[1]);
|
||||
setMissingEntryGenerator((key) => key.split("|", 2)[1]);
|
||||
matrixClient = getMockClientWithEventEmitter({
|
||||
getRoom: jest.fn(),
|
||||
getUserId: jest.fn(),
|
||||
|
||||
Reference in New Issue
Block a user