Move more tests from Jest to Vitest (#34181)
* Move more tests from Jest to Vitest * Iterate
This commit is contained in:
@@ -21,6 +21,7 @@ export * from "./utilities";
|
||||
export * from "./date";
|
||||
export * from "./relations";
|
||||
export * from "./console";
|
||||
export * from "../unit-tests/TestSDKContext.ts";
|
||||
|
||||
// wait for loading page
|
||||
export async function waitForLoadingSpinner(): Promise<void> {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
Copyright 2024 New Vector Ltd.
|
||||
Copyright 2022 The Matrix.org Foundation C.I.C.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import { cleanup } from "@testing-library/react";
|
||||
import { afterEach } from "vitest";
|
||||
|
||||
afterEach(cleanup);
|
||||
|
||||
export * from "./jest-matrix-react.tsx";
|
||||
@@ -14,6 +14,8 @@ import { MatrixClientPeg as peg } from "../../src/MatrixClientPeg";
|
||||
import MatrixClientContext from "../../src/contexts/MatrixClientContext";
|
||||
import { SDKContext } from "../../src/contexts/SDKContext";
|
||||
import { type SDKContextClass } from "../../src/contexts/SDKContextClass";
|
||||
import { type RoomContextType } from "../../src/contexts/RoomContext.ts";
|
||||
import { ScopedRoomContextProvider } from "../../src/contexts/ScopedRoomContext.tsx";
|
||||
|
||||
type WrapperProps<T> = { wrappedRef?: Ref<ComponentType<T>> } & T;
|
||||
|
||||
@@ -73,3 +75,28 @@ export function clientAndSDKContextRenderOptions(client: MatrixClient, sdkContex
|
||||
),
|
||||
};
|
||||
}
|
||||
export function withContexts({
|
||||
sdkContext,
|
||||
matrixClient,
|
||||
roomContext,
|
||||
}: {
|
||||
sdkContext?: SDKContextClass;
|
||||
matrixClient?: MatrixClient;
|
||||
roomContext?: RoomContextType;
|
||||
}): RenderOptions {
|
||||
return {
|
||||
wrapper: ({ children }) => {
|
||||
const client = matrixClient || sdkContext?.client;
|
||||
if (client) {
|
||||
children = <MatrixClientContext.Provider value={client}>{children}</MatrixClientContext.Provider>;
|
||||
}
|
||||
if (sdkContext) {
|
||||
children = <SDKContext.Provider value={sdkContext}>{children}</SDKContext.Provider>;
|
||||
}
|
||||
if (roomContext) {
|
||||
children = <ScopedRoomContextProvider {...roomContext}>{children}</ScopedRoomContextProvider>;
|
||||
}
|
||||
return children;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user