|
| 1 | +import * as React from 'react'; |
| 2 | +import { ReactTestInstance } from 'react-test-renderer'; |
| 3 | + |
| 4 | +export interface GetByAPI { |
| 5 | + getByName: (name: React.ReactType) => ReactTestInstance; |
| 6 | + getByText: (text: string | RegExp) => ReactTestInstance; |
| 7 | + getByProps: (props: Record<string, any>) => ReactTestInstance; |
| 8 | + getByTestId: (testID: string) => ReactTestInstance; |
| 9 | + getAllByName: (name: React.ReactType) => Array<ReactTestInstance>; |
| 10 | + getAllByText: (text: string | RegExp) => Array<ReactTestInstance>; |
| 11 | + getAllByProps: (props: Record<string, any>) => Array<ReactTestInstance>; |
| 12 | +} |
| 13 | + |
| 14 | +export interface QueryByAPI { |
| 15 | + queryByName: (name: React.ReactType) => ReactTestInstance | null; |
| 16 | + queryByText: (name: string | RegExp) => ReactTestInstance | null; |
| 17 | + queryByProps: (props: Record<string, any>) => ReactTestInstance | null; |
| 18 | + queryByTestId: (testID: string) => ReactTestInstance | null; |
| 19 | + queryAllByName: (name: React.ReactType) => Array<ReactTestInstance> | []; |
| 20 | + queryAllByText: (text: string | RegExp) => Array<ReactTestInstance> | []; |
| 21 | + queryAllByProps: ( |
| 22 | + props: Record<string, any> |
| 23 | + ) => Array<ReactTestInstance> | []; |
| 24 | +} |
| 25 | + |
| 26 | +export interface RenderOptions { |
| 27 | + createNodeMock: (element: React.ReactElement<any>) => any; |
| 28 | +} |
| 29 | + |
| 30 | +export interface RenderAPI extends GetByAPI, QueryByAPI { |
| 31 | + update(nextElement: React.ReactElement<any>): void; |
| 32 | + unmount(nextElement?: React.ReactElement<any>): void; |
| 33 | +} |
| 34 | + |
| 35 | +export type FireEventFunction = ( |
| 36 | + element: ReactTestInstance, |
| 37 | + eventName: string, |
| 38 | + data?: any |
| 39 | +) => any; |
| 40 | + |
| 41 | +export type FireEventAPI = FireEventFunction & { |
| 42 | + press: (element: ReactTestInstance) => any; |
| 43 | + doublePress: (element: ReactTestInstance) => any; |
| 44 | + changeText: (element: ReactTestInstance, data?: any) => any; |
| 45 | + scroll: (element: ReactTestInstance, data?: any) => any; |
| 46 | +}; |
| 47 | + |
| 48 | +export declare const render: ( |
| 49 | + component: React.ReactElement<any>, |
| 50 | + options?: RenderOptions |
| 51 | +) => RenderAPI; |
| 52 | +export declare const shallow: <P = {}>( |
| 53 | + instance: ReactTestInstance | React.ReactElement<P> |
| 54 | +) => { output: React.ReactElement<P> }; |
| 55 | +export declare const flushMicrotasksQueue: () => Promise<any>; |
| 56 | +export declare const debug: ( |
| 57 | + instance: ReactTestInstance | React.ReactElement<any> |
| 58 | +) => void; |
| 59 | +export declare const fireEvent: FireEventAPI; |
0 commit comments