You've already forked matrix-react-sdk
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:
committed by
GitHub
parent
b40f29f04c
commit
9c48487d85
@ -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>
|
||||
),
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user