Make tests happier
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
4367299885
commit
7fe11a6026
7 changed files with 21 additions and 5 deletions
|
@ -25,10 +25,7 @@ const config: Config = {
|
||||||
},
|
},
|
||||||
testMatch: ["<rootDir>/test/**/*-test.[tj]s?(x)"],
|
testMatch: ["<rootDir>/test/**/*-test.[tj]s?(x)"],
|
||||||
setupFiles: ["jest-canvas-mock"],
|
setupFiles: ["jest-canvas-mock"],
|
||||||
setupFilesAfterEnv: [
|
setupFilesAfterEnv: ["<rootDir>/node_modules/matrix-react-sdk/test/setupTests.ts"],
|
||||||
"<rootDir>/node_modules/matrix-react-sdk/test/setupTests.ts",
|
|
||||||
"<rootDir>/test/setup/setupLanguage.ts",
|
|
||||||
],
|
|
||||||
moduleNameMapper: {
|
moduleNameMapper: {
|
||||||
"\\.(css|scss|pcss)$": "<rootDir>/__mocks__/cssMock.js",
|
"\\.(css|scss|pcss)$": "<rootDir>/__mocks__/cssMock.js",
|
||||||
"\\.(gif|png|ttf|woff2)$": "<rootDir>/node_modules/matrix-react-sdk/__mocks__/imageMock.js",
|
"\\.(gif|png|ttf|woff2)$": "<rootDir>/node_modules/matrix-react-sdk/__mocks__/imageMock.js",
|
||||||
|
|
|
@ -25,6 +25,6 @@ fetchMock.config.overwriteRoutes = false;
|
||||||
|
|
||||||
export function setupLanguageMock() {
|
export function setupLanguageMock() {
|
||||||
reactSetupLanguageMock();
|
reactSetupLanguageMock();
|
||||||
fetchMock.get("end:en_EN.json", _.merge(en, reactEn), { overwriteRoutes: true });
|
fetchMock.get("end:en_EN.json", _.merge({}, en, reactEn), { overwriteRoutes: true });
|
||||||
}
|
}
|
||||||
setupLanguageMock();
|
setupLanguageMock();
|
||||||
|
|
|
@ -18,8 +18,13 @@ import * as React from "react";
|
||||||
import { render } from "@testing-library/react";
|
import { render } from "@testing-library/react";
|
||||||
|
|
||||||
import ErrorView from "../../../../src/async-components/structures/ErrorView";
|
import ErrorView from "../../../../src/async-components/structures/ErrorView";
|
||||||
|
import { setupLanguageMock } from "../../../setup/setupLanguage";
|
||||||
|
|
||||||
describe("<ErrorView />", () => {
|
describe("<ErrorView />", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
setupLanguageMock();
|
||||||
|
});
|
||||||
|
|
||||||
it("should match snapshot", () => {
|
it("should match snapshot", () => {
|
||||||
const { asFragment } = render(<ErrorView title="TITLE" messages={["MSG1", "MSG2"]} />);
|
const { asFragment } = render(<ErrorView title="TITLE" messages={["MSG1", "MSG2"]} />);
|
||||||
expect(asFragment()).toMatchSnapshot();
|
expect(asFragment()).toMatchSnapshot();
|
||||||
|
|
|
@ -18,8 +18,13 @@ import * as React from "react";
|
||||||
import { render } from "@testing-library/react";
|
import { render } from "@testing-library/react";
|
||||||
|
|
||||||
import VectorAuthFooter from "../../../../../src/components/views/auth/VectorAuthFooter";
|
import VectorAuthFooter from "../../../../../src/components/views/auth/VectorAuthFooter";
|
||||||
|
import { setupLanguageMock } from "../../../../setup/setupLanguage";
|
||||||
|
|
||||||
describe("<VectorAuthFooter />", () => {
|
describe("<VectorAuthFooter />", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
setupLanguageMock();
|
||||||
|
});
|
||||||
|
|
||||||
it("should match snapshot", () => {
|
it("should match snapshot", () => {
|
||||||
const { asFragment } = render(<VectorAuthFooter />);
|
const { asFragment } = render(<VectorAuthFooter />);
|
||||||
expect(asFragment()).toMatchSnapshot();
|
expect(asFragment()).toMatchSnapshot();
|
||||||
|
|
|
@ -18,8 +18,13 @@ import * as React from "react";
|
||||||
import { render } from "@testing-library/react";
|
import { render } from "@testing-library/react";
|
||||||
|
|
||||||
import VectorAuthPage from "../../../../../src/components/views/auth/VectorAuthPage";
|
import VectorAuthPage from "../../../../../src/components/views/auth/VectorAuthPage";
|
||||||
|
import { setupLanguageMock } from "../../../../setup/setupLanguage";
|
||||||
|
|
||||||
describe("<VectorAuthPage />", () => {
|
describe("<VectorAuthPage />", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
setupLanguageMock();
|
||||||
|
});
|
||||||
|
|
||||||
it("should match snapshot", () => {
|
it("should match snapshot", () => {
|
||||||
const { asFragment } = render(<VectorAuthPage />);
|
const { asFragment } = render(<VectorAuthPage />);
|
||||||
expect(asFragment()).toMatchSnapshot();
|
expect(asFragment()).toMatchSnapshot();
|
||||||
|
|
|
@ -26,6 +26,7 @@ import DesktopCapturerSourcePicker from "matrix-react-sdk/src/components/views/e
|
||||||
import { mocked } from "jest-mock";
|
import { mocked } from "jest-mock";
|
||||||
|
|
||||||
import ElectronPlatform from "../../../../src/vector/platform/ElectronPlatform";
|
import ElectronPlatform from "../../../../src/vector/platform/ElectronPlatform";
|
||||||
|
import { setupLanguageMock } from "../../../setup/setupLanguage";
|
||||||
|
|
||||||
jest.mock("matrix-react-sdk/src/rageshake/rageshake", () => ({
|
jest.mock("matrix-react-sdk/src/rageshake/rageshake", () => ({
|
||||||
flush: jest.fn(),
|
flush: jest.fn(),
|
||||||
|
@ -51,6 +52,7 @@ describe("ElectronPlatform", () => {
|
||||||
window.electron = mockElectron;
|
window.electron = mockElectron;
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
Object.defineProperty(window, "navigator", { value: { userAgent: defaultUserAgent }, writable: true });
|
Object.defineProperty(window, "navigator", { value: { userAgent: defaultUserAgent }, writable: true });
|
||||||
|
setupLanguageMock();
|
||||||
});
|
});
|
||||||
|
|
||||||
const getElectronEventHandlerCall = (eventType: string): [type: string, handler: Function] | undefined =>
|
const getElectronEventHandlerCall = (eventType: string): [type: string, handler: Function] | undefined =>
|
||||||
|
|
|
@ -19,12 +19,14 @@ import { UpdateCheckStatus } from "matrix-react-sdk/src/BasePlatform";
|
||||||
import { MatrixClientPeg } from "matrix-react-sdk/src/MatrixClientPeg";
|
import { MatrixClientPeg } from "matrix-react-sdk/src/MatrixClientPeg";
|
||||||
|
|
||||||
import WebPlatform from "../../../../src/vector/platform/WebPlatform";
|
import WebPlatform from "../../../../src/vector/platform/WebPlatform";
|
||||||
|
import { setupLanguageMock } from "../../../setup/setupLanguage";
|
||||||
|
|
||||||
fetchMock.config.overwriteRoutes = true;
|
fetchMock.config.overwriteRoutes = true;
|
||||||
|
|
||||||
describe("WebPlatform", () => {
|
describe("WebPlatform", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
|
setupLanguageMock();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns human readable name", () => {
|
it("returns human readable name", () => {
|
||||||
|
|
Loading…
Reference in a new issue