fleet/frontend/test/test-utils.tsx
Gabriel Hernandez eb06ef8049
simplify TeamsDropdown component and update ManageHostPage to keep po… (#7606)
* simplify TeamsDropdown component and update ManageHostPage to keep policy filter across team change

* fix TeamDropdown for users not on global team
2022-09-12 16:18:12 +01:00

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
);
};