|
// Inspired by the Type definitions for Enzyme v2.4.1 |
|
// Project: https://github.com/airbnb/enzyme |
|
// Definitions by: Marian Palkus <https://github.com/MarianPalkus>, Cap3 <http://www.cap3.de> |
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped |
|
|
|
import { StatelessComponent, HTMLAttributes } from "react"; |
|
type ReactElement<T> = any; |
|
|
|
export type EnzymeSelector = string | StatelessComponent<any> | { [key: string]: any }; |
|
export type EnzymePropSelector = { [key: string]: any }; |
|
|
|
interface CommonWrapper<P, S> { |
|
find<P2>(statelessComponent: StatelessComponent<P2>): CommonWrapper<P2, {}>; |
|
find(selector: string): CommonWrapper<HTMLAttributes<{}>, any>; |
|
|
|
findWhere(predicate: (wrapper: CommonWrapper<any, any>) => boolean): CommonWrapper<any, any>; |
|
|
|
filter<P2>(statelessComponent: StatelessComponent<P2>): CommonWrapper<P2, {}>; |
|
filter(selector: string): CommonWrapper<HTMLAttributes<{}>, any>; |
|
|
|
children<P2>(statelessComponent: StatelessComponent<P2>): CommonWrapper<P2, {}>; |
|
children(selector: string): CommonWrapper<HTMLAttributes<{}>, any>; |
|
children(): CommonWrapper<any, any>; |
|
|
|
childAt(index: number): CommonWrapper<any, any>; |
|
childAt<P2, S2>(index: number): CommonWrapper<P2, S2>; |
|
|
|
parents<P2>(statelessComponent: StatelessComponent<P2>): CommonWrapper<P2, {}>; |
|
parents(selector: string): CommonWrapper<HTMLAttributes<{}>, any>; |
|
parents(): CommonWrapper<any, any>; |
|
|
|
parent(): CommonWrapper<any, any>; |
|
|
|
closest<P2>(statelessComponent: StatelessComponent<P2>): CommonWrapper<P2, {}>; |
|
closest(selector: string): CommonWrapper<HTMLAttributes<{}>, any>; |
|
|
|
text(): string; |
|
html(): string; |
|
get(index: number): ReactElement<any>; |
|
at(index: number): this; |
|
first(): this; |
|
last(): this; |
|
state(key?: string): any; |
|
state<T>(key?: string): T; |
|
context(key?: string): any; |
|
context<T>(key?: string): T; |
|
props(): P; |
|
prop(key: string): any; |
|
prop<T>(key: string): T; |
|
key(): string; |
|
simulate(event: string, ...args: any[]): this; |
|
setState(state: S): this; |
|
setProps(props: P): this; |
|
setContext(context: Object): this; |
|
update(): this; |
|
debug(): string; |
|
type(): string | Function; |
|
name(): string; |
|
forEach(fn: (wrapper: this) => any): this; |
|
map<V>(fn: (wrapper: this) => V): V[]; |
|
reduce<R>(fn: (prevVal: R, wrapper: this, index: number) => R, initialValue?: R): R[]; |
|
reduceRight<R>(fn: (prevVal: R, wrapper: this, index: number) => R, initialValue?: R): R[]; |
|
some(selector: EnzymeSelector): boolean; |
|
someWhere(fn: (wrapper: this) => boolean): boolean; |
|
every(selector: EnzymeSelector): boolean; |
|
everyWhere(fn: (wrapper: this) => boolean): boolean; |
|
length: number; |
|
} |
|
|
|
export interface ShallowWrapper<P, S> extends CommonWrapper<P, S> { |
|
|
|
shallow(): ShallowWrapper<P, S>; |
|
unmount(): ShallowWrapper<any, any>; |
|
|
|
find<P2>(statelessComponent: (props: P2) => JSX.Element): ShallowWrapper<P2, {}>; |
|
find(selector: string): ShallowWrapper<HTMLAttributes<{}>, any>; |
|
|
|
filter<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, {}>; |
|
filter(selector: string): ShallowWrapper<HTMLAttributes<{}>, any>; |
|
|
|
findWhere(predicate: (wrapper: CommonWrapper<any, any>) => boolean): ShallowWrapper<any, any>; |
|
|
|
children<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, {}>; |
|
children(selector: string): ShallowWrapper<HTMLAttributes<{}>, any>; |
|
children(): ShallowWrapper<any, any>; |
|
|
|
childAt(index: number): ShallowWrapper<any, any>; |
|
childAt<P2, S2>(index: number): ShallowWrapper<P2, S2>; |
|
|
|
parents<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, {}>; |
|
parents(selector: string): ShallowWrapper<HTMLAttributes<{}>, any>; |
|
parents(): ShallowWrapper<any, any>; |
|
|
|
closest<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, {}>; |
|
closest(selector: string): ShallowWrapper<HTMLAttributes<{}>, any>; |
|
|
|
parent(): ShallowWrapper<any, any>; |
|
isEmptyRender(): boolean; |
|
} |
|
|
|
export interface ReactWrapper<P, S> extends CommonWrapper<P, S> { |
|
unmount(): ReactWrapper<any, any>; |
|
mount(): ReactWrapper<any, any>; |
|
|
|
ref(refName: string): ReactWrapper<any, any>; |
|
ref<P2, S2>(refName: string): ReactWrapper<P2, S2>; |
|
|
|
detach(): void; |
|
|
|
find<P2>(statelessComponent: (props: P2) => JSX.Element): ReactWrapper<P2, {}>; |
|
find(selector: string): ReactWrapper<HTMLAttributes<{}>, any>; |
|
|
|
findWhere(predicate: (wrapper: CommonWrapper<any, any>) => boolean): ReactWrapper<any, any>; |
|
|
|
filter<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, {}>; |
|
filter(selector: string): ReactWrapper<HTMLAttributes<{}>, any>; |
|
|
|
children<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, {}>; |
|
children(selector: string): ReactWrapper<HTMLAttributes<{}>, any>; |
|
children(): ReactWrapper<any, any>; |
|
|
|
childAt(index: number): ReactWrapper<any, any>; |
|
childAt<P2, S2>(index: number): ReactWrapper<P2, S2>; |
|
|
|
parents<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, {}>; |
|
parents(selector: string): ReactWrapper<HTMLAttributes<{}>, any>; |
|
parents(): ReactWrapper<any, any>; |
|
|
|
closest<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, {}>; |
|
closest(selector: string): ReactWrapper<HTMLAttributes<{}>, any>; |
|
|
|
parent(): ReactWrapper<any, any>; |
|
isEmptyRender(): boolean; |
|
} |