mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 01:15:22 +00:00
eb06ef8049
* simplify TeamsDropdown component and update ManageHostPage to keep policy filter across team change * fix TeamDropdown for users not on global team
24 lines
744 B
TypeScript
24 lines
744 B
TypeScript
import React from "react";
|
|
import { render, RenderOptions } from "@testing-library/react";
|
|
|
|
import { AppContext, IAppContext, initialState } from "context/app";
|
|
|
|
type RenderOptionsWithProviderProps = RenderOptions & {
|
|
contextValue: Partial<IAppContext>;
|
|
};
|
|
|
|
/**
|
|
* A custom render method that provides a configurable App context when testing components
|
|
*/
|
|
// eslint-disable-next-line import/prefer-default-export
|
|
export const renderWithAppContext = (
|
|
component: React.ReactNode,
|
|
{ contextValue, ...renderOptions }: RenderOptionsWithProviderProps
|
|
) => {
|
|
const value: IAppContext = { ...initialState, ...contextValue };
|
|
return render(
|
|
<AppContext.Provider value={value}>{component}</AppContext.Provider>,
|
|
renderOptions
|
|
);
|
|
};
|