1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-08-09 08:42:50 +03:00

Fix instances of double translation and guard translation calls using typescript (#11443)

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
This commit is contained in:
Michael Telatynski
2023-08-22 16:32:05 +01:00
committed by GitHub
parent d13b6e1b41
commit ac70f7ac9b
157 changed files with 554 additions and 780 deletions

View File

@@ -21,6 +21,7 @@ import { render, screen } from "@testing-library/react";
import { shouldShowFeedback } from "../../../../src/utils/Feedback";
import BetaCard from "../../../../src/components/views/beta/BetaCard";
import SettingsStore from "../../../../src/settings/SettingsStore";
import { TranslationKey } from "../../../../src/languageHandler";
jest.mock("../../../../src/utils/Feedback");
jest.mock("../../../../src/settings/SettingsStore");
@@ -31,10 +32,10 @@ describe("<BetaCard />", () => {
beforeEach(() => {
mocked(SettingsStore).getBetaInfo.mockReturnValue({
title: "title",
title: "title" as TranslationKey,
caption: () => "caption",
feedbackLabel: "feedbackLabel",
feedbackSubheading: "feedbackSubheading",
feedbackSubheading: "feedbackSubheading" as TranslationKey,
});
mocked(SettingsStore).getValue.mockReturnValue(true);
mocked(shouldShowFeedback).mockReturnValue(true);
@@ -53,9 +54,9 @@ describe("<BetaCard />", () => {
it("should not show feedback prompt if label is unset", () => {
mocked(SettingsStore).getBetaInfo.mockReturnValue({
title: "title",
title: "title" as TranslationKey,
caption: () => "caption",
feedbackSubheading: "feedbackSubheading",
feedbackSubheading: "feedbackSubheading" as TranslationKey,
});
render(<BetaCard featureId={featureId} />);
expect(screen.queryByText("Feedback")).toBeFalsy();
@@ -63,7 +64,7 @@ describe("<BetaCard />", () => {
it("should not show feedback prompt if subheading is unset", () => {
mocked(SettingsStore).getBetaInfo.mockReturnValue({
title: "title",
title: "title" as TranslationKey,
caption: () => "caption",
feedbackLabel: "feedbackLabel",
});

View File

@@ -19,7 +19,7 @@ import { fireEvent, render, screen } from "@testing-library/react";
import { IThreepid, ThreepidMedium } from "matrix-js-sdk/src/@types/threepids";
import { IRequestTokenResponse, MatrixError } from "matrix-js-sdk/src/matrix";
import { UserFriendlyError } from "../../../../../src/languageHandler";
import { TranslationKey, UserFriendlyError } from "../../../../../src/languageHandler";
import EmailAddresses, { EmailAddress } from "../../../../../src/components/views/settings/discovery/EmailAddresses";
import { clearAllModals, getMockClientWithEventEmitter } from "../../../../test-utils";
@@ -119,7 +119,7 @@ describe("<EmailAddress/>", () => {
});
it("Shows error dialog when share completion fails (UserFriendlyError)", async () => {
const fakeErrorText = "Fake UserFriendlyError error in test";
const fakeErrorText = "Fake UserFriendlyError error in test" as TranslationKey;
mockClient.bindThreePid.mockRejectedValue(new UserFriendlyError(fakeErrorText));
fireEvent.click(screen.getByText("Complete"));