1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-07-30 02:21:17 +03:00

Prefer MatrixClientContext over MatrixClientPeg (#10986)

This commit is contained in:
Michael Telatynski
2023-06-14 13:42:07 +01:00
committed by GitHub
parent b40f29f04c
commit 9c48487d85
20 changed files with 120 additions and 87 deletions

View File

@ -16,6 +16,7 @@ limitations under the License.
import React, { ComponentType, Ref } from "react";
import { MatrixClient } from "matrix-js-sdk/src/matrix";
import { RenderOptions } from "@testing-library/react";
import { MatrixClientPeg as peg } from "../../src/MatrixClientPeg";
import MatrixClientContext from "../../src/contexts/MatrixClientContext";
@ -57,3 +58,15 @@ export function wrapInSdkContext<T>(
}
};
}
/**
* Test helper to generate React testing library render options for wrapping with a MatrixClientContext.Provider
* @param client the MatrixClient instance to expose via the provider
*/
export function withClientContextRenderOptions(client: MatrixClient): RenderOptions {
return {
wrapper: ({ children }) => (
<MatrixClientContext.Provider value={client}>{children}</MatrixClientContext.Provider>
),
};
}