test(web): fix tests to conform to react18 (#3466)

This change drops the use of ReactDOM which is not supported in React 18. We also fix any test warnings related to i18next.
This commit is contained in:
Amir Zarrinkafsh 2022-06-03 10:17:00 +10:00 committed by GitHub
parent f07f6b7dda
commit bbeab861b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 9 deletions

View File

@ -3,6 +3,7 @@ import React from "react";
import { render } from "@testing-library/react";
import App from "@root/App";
import "@i18n/index.ts";
it("renders without crashing", () => {
render(<App />);

View File

@ -1,11 +1,9 @@
import React from "react";
import ReactDOM from "react-dom";
import { render } from "@testing-library/react";
import AppStoreBadges from "@components/AppStoreBadges";
it("renders without crashing", () => {
const div = document.createElement("div");
ReactDOM.render(<AppStoreBadges iconSize={32} appleStoreLink="http://apple" googlePlayLink="http://google" />, div);
ReactDOM.unmountComponentAtNode(div);
render(<AppStoreBadges iconSize={32} appleStoreLink="http://apple" googlePlayLink="http://google" />);
});

View File

@ -1,14 +1,12 @@
import React from "react";
import { render, screen } from "@testing-library/react";
import ReactDOM from "react-dom";
import ColoredSnackbarContent from "@components/ColoredSnackbarContent";
it("renders without crashing", () => {
const div = document.createElement("div");
ReactDOM.render(<ColoredSnackbarContent level="success" message="this is a success" />, div);
ReactDOM.unmountComponentAtNode(div);
render(<ColoredSnackbarContent level="success" message="" />);
expect(screen.getByRole("alert")).toHaveTextContent("");
});
it("should contain the message", () => {

View File

@ -3,6 +3,7 @@ import React from "react";
import { render } from "@testing-library/react";
import PasswordMeter from "@components/PasswordMeter";
import "@i18n/index.ts";
import { PasswordPolicyMode } from "@models/PasswordPolicy";
it("renders without crashing", () => {

View File

@ -17,7 +17,7 @@ const PasswordMeter = function (props: Props) {
const [passwordScore, setPasswordScore] = useState(0);
const [maxScores, setMaxScores] = useState(0);
const [feedback, setFeedback] = useState("");
const { t: translate } = useTranslation("Portal");
const { t: translate } = useTranslation();
const style = makeStyles((theme) => ({
progressBar: {
height: "5px",