UNPKG

enzyme-context

Version:

Enzyme Context is a pluggable library which simplifies the process of testing components that rely on react context.

23 lines 2.1 kB
import { ReactElement, Component } from 'react'; import { ReactWrapper, ShallowWrapper, MountRendererProps, ShallowRendererProps } from 'enzyme'; import { EnzymePlugins, GetContextWrapper, GetOptions } from './Types'; export { GetContextWrapper, GetOptions }; /** * Creates a specialized enzyme mount() function with context set up. * * @param plugins an object where the keys are names of your choice and the values are `enzyme-context` [`MountPlugin`](https://github.com/trialspark/enzyme-context/blob/007022a7bddb7e843a27563f7918276af2ebb707/packages/enzyme-context-utils/src/Types.ts#L4-L12)s. */ export declare function createMount<P extends EnzymePlugins>(plugins: P): { <C extends Component<{}, {}, any>, P_1 = C["props"], S = C["state"]>(node: ReactElement<P_1, string | import("react").JSXElementConstructor<any>>, options?: GetOptions<MountRendererProps, P> | undefined): GetContextWrapper<ReactWrapper<P_1, S, C>, P>; <P_2>(node: ReactElement<P_2, string | import("react").JSXElementConstructor<any>>, options?: GetOptions<MountRendererProps, P> | undefined): GetContextWrapper<ReactWrapper<P_2, any, Component<{}, {}, any>>, P>; }; /** * Creates a specialized enzyme shallow() function with context set up. * * @param plugins an object where the keys are names of your choice and the values are `enzyme-context` [`MountPlugin`](https://github.com/trialspark/enzyme-context/blob/007022a7bddb7e843a27563f7918276af2ebb707/packages/enzyme-context-utils/src/Types.ts#L4-L12)s. */ export declare function createShallow<P extends EnzymePlugins>(plugins: P): { <C extends Component<{}, {}, any>, P_1 = C["props"], S = C["state"]>(node: ReactElement<P_1, string | import("react").JSXElementConstructor<any>>, options?: GetOptions<ShallowRendererProps, P> | undefined): GetContextWrapper<ShallowWrapper<P_1, S, C>, P>; <P_2>(node: ReactElement<P_2, string | import("react").JSXElementConstructor<any>>, options?: GetOptions<ShallowRendererProps, P> | undefined): GetContextWrapper<ShallowWrapper<P_2, any, Component<{}, {}, any>>, P>; }; //# sourceMappingURL=index.d.ts.map