|
| 1 | +// flow-typed signature: 9b9f4128694a7f68659d945b81fb78ff |
| 2 | +// flow-typed version: 46dfe79a54/react-test-renderer_v16.x.x/flow_>=v0.47.x |
| 3 | + |
| 4 | +// Type definitions for react-test-renderer 16.x.x |
| 5 | +// Ported from: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-test-renderer |
| 6 | + |
| 7 | +type ReactComponentInstance = React$Component<any>; |
| 8 | + |
| 9 | +type ReactTestRendererJSON = { |
| 10 | + type: string, |
| 11 | + props: { [propName: string]: any }, |
| 12 | + children: null | ReactTestRendererJSON[] |
| 13 | +}; |
| 14 | + |
| 15 | +type ReactTestRendererTree = ReactTestRendererJSON & { |
| 16 | + nodeType: "component" | "host", |
| 17 | + instance: ?ReactComponentInstance, |
| 18 | + rendered: null | ReactTestRendererTree |
| 19 | +}; |
| 20 | + |
| 21 | +type ReactTestInstance = { |
| 22 | + instance: ?ReactComponentInstance, |
| 23 | + type: string | Function, |
| 24 | + props: { [propName: string]: any }, |
| 25 | + parent: null | ReactTestInstance, |
| 26 | + children: Array<ReactTestInstance | string>, |
| 27 | + |
| 28 | + find(predicate: (node: ReactTestInstance) => boolean): ReactTestInstance, |
| 29 | + findByType(type: React$ElementType): ReactTestInstance, |
| 30 | + findByProps(props: { [propName: string]: any }): ReactTestInstance, |
| 31 | + |
| 32 | + findAll( |
| 33 | + predicate: (node: ReactTestInstance) => boolean, |
| 34 | + options?: { deep: boolean } |
| 35 | + ): ReactTestInstance[], |
| 36 | + findAllByType( |
| 37 | + type: React$ElementType, |
| 38 | + options?: { deep: boolean } |
| 39 | + ): ReactTestInstance[], |
| 40 | + findAllByProps( |
| 41 | + props: { [propName: string]: any }, |
| 42 | + options?: { deep: boolean } |
| 43 | + ): ReactTestInstance[] |
| 44 | +}; |
| 45 | + |
| 46 | +type TestRendererOptions = { |
| 47 | + createNodeMock(element: React$Element<any>): any |
| 48 | +}; |
| 49 | + |
| 50 | +declare module "react-test-renderer" { |
| 51 | + declare export type ReactTestRenderer = { |
| 52 | + toJSON(): null | ReactTestRendererJSON, |
| 53 | + toTree(): null | ReactTestRendererTree, |
| 54 | + unmount(nextElement?: React$Element<any>): void, |
| 55 | + update(nextElement: React$Element<any>): void, |
| 56 | + getInstance(): ?ReactComponentInstance, |
| 57 | + root: ReactTestInstance |
| 58 | + }; |
| 59 | + |
| 60 | + declare function create( |
| 61 | + nextElement: React$Element<any>, |
| 62 | + options?: TestRendererOptions |
| 63 | + ): ReactTestRenderer; |
| 64 | +} |
| 65 | + |
| 66 | +declare module "react-test-renderer/shallow" { |
| 67 | + declare export default class ShallowRenderer { |
| 68 | + static createRenderer(): ShallowRenderer; |
| 69 | + getMountedInstance(): ReactTestInstance; |
| 70 | + getRenderOutput<E: React$Element<any>>(): E; |
| 71 | + getRenderOutput(): React$Element<any>; |
| 72 | + render(element: React$Element<any>, context?: any): void; |
| 73 | + unmount(): void; |
| 74 | + } |
| 75 | +} |
0 commit comments