Skip to content

Commit

Permalink
Consolidate enzyme use of {} in one place as a work around for micr…
Browse files Browse the repository at this point in the history
  • Loading branch information
mhegazy committed Sep 26, 2016
1 parent dfba1cf commit 8cd8119
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions enzyme/index.d.ts
Expand Up @@ -3,7 +3,9 @@
// Definitions by: Marian Palkus <https://github.com/MarianPalkus>, Cap3 <http://www.cap3.de>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

import { ReactElement, Component, StatelessComponent, ComponentClass, HTMLAttributes } from "react";
import { ReactElement, Component, StatelessComponent, ComponentClass, HTMLAttributes as ReactHTMLAttributes } from "react";

type HTMLAttributes = ReactHTMLAttributes<{}>;

export class ElementClass extends Component<any, any> {
}
Expand All @@ -29,7 +31,7 @@ interface CommonWrapper<P, S> {
find<P2>(component: ComponentClass<P2>): CommonWrapper<P2, any>;
find<P2>(statelessComponent: StatelessComponent<P2>): CommonWrapper<P2, {}>;
find(props: EnzymePropSelector): CommonWrapper<any, any>;
find(selector: string): CommonWrapper<HTMLAttributes<{}>, any>;
find(selector: string): CommonWrapper<HTMLAttributes, any>;

/**
* Finds every node in the render tree that returns true for the provided predicate function.
Expand All @@ -44,7 +46,7 @@ interface CommonWrapper<P, S> {
filter<P2>(component: ComponentClass<P2>): CommonWrapper<P2, any>;
filter<P2>(statelessComponent: StatelessComponent<P2>): CommonWrapper<P2, {}>;
filter(props: EnzymePropSelector): CommonWrapper<any, any>;
filter(selector: string): CommonWrapper<HTMLAttributes<{}>, any>;
filter(selector: string): CommonWrapper<HTMLAttributes, any>;

/**
* Returns a new wrapper with only the nodes of the current wrapper that, when passed into the provided predicate function, return true.
Expand Down Expand Up @@ -113,7 +115,7 @@ interface CommonWrapper<P, S> {
children<P2>(component: ComponentClass<P2>): CommonWrapper<P2, any>;
children<P2>(statelessComponent: StatelessComponent<P2>): CommonWrapper<P2, {}>;
children(props: EnzymePropSelector): CommonWrapper<any, any>;
children(selector: string): CommonWrapper<HTMLAttributes<{}>, any>;
children(selector: string): CommonWrapper<HTMLAttributes, any>;
children(): CommonWrapper<any, any>;

/**
Expand All @@ -133,7 +135,7 @@ interface CommonWrapper<P, S> {
parents<P2>(component: ComponentClass<P2>): CommonWrapper<P2, any>;
parents<P2>(statelessComponent: StatelessComponent<P2>): CommonWrapper<P2, {}>;
parents(props: EnzymePropSelector): CommonWrapper<any, any>;
parents(selector: string): CommonWrapper<HTMLAttributes<{}>, any>;
parents(selector: string): CommonWrapper<HTMLAttributes, any>;
parents(): CommonWrapper<any, any>;

/**
Expand All @@ -151,7 +153,7 @@ interface CommonWrapper<P, S> {
closest<P2>(component: ComponentClass<P2>): CommonWrapper<P2, any>;
closest<P2>(statelessComponent: StatelessComponent<P2>): CommonWrapper<P2, {}>;
closest(props: EnzymePropSelector): CommonWrapper<any, any>;
closest(selector: string): CommonWrapper<HTMLAttributes<{}>, any>;
closest(selector: string): CommonWrapper<HTMLAttributes, any>;

/**
* Returns a string of the rendered text of the current render tree. This function should be looked at with
Expand Down Expand Up @@ -380,7 +382,7 @@ export interface ShallowWrapper<P, S> extends CommonWrapper<P, S> {
find<P2>(component: ComponentClass<P2>): ShallowWrapper<P2, any>;
find<P2>(statelessComponent: (props: P2) => JSX.Element): ShallowWrapper<P2, {}>;
find(props: EnzymePropSelector): ShallowWrapper<any, any>;
find(selector: string): ShallowWrapper<HTMLAttributes<{}>, any>;
find(selector: string): ShallowWrapper<HTMLAttributes, any>;

/**
* Removes nodes in the current wrapper that do not match the provided selector.
Expand All @@ -389,7 +391,7 @@ export interface ShallowWrapper<P, S> extends CommonWrapper<P, S> {
filter<P2>(component: ComponentClass<P2>): ShallowWrapper<P2, any>;
filter<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, {}>;
filter(props: EnzymePropSelector): ShallowWrapper<any, any>;
filter(selector: string): ShallowWrapper<HTMLAttributes<{}>, any>;
filter(selector: string): ShallowWrapper<HTMLAttributes, any>;

/**
* Finds every node in the render tree that returns true for the provided predicate function.
Expand All @@ -405,7 +407,7 @@ export interface ShallowWrapper<P, S> extends CommonWrapper<P, S> {
children<P2>(component: ComponentClass<P2>): ShallowWrapper<P2, any>;
children<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, {}>;
children(props: EnzymePropSelector): ShallowWrapper<any, any>;
children(selector: string): ShallowWrapper<HTMLAttributes<{}>, any>;
children(selector: string): ShallowWrapper<HTMLAttributes, any>;
children(): ShallowWrapper<any, any>;

/**
Expand All @@ -425,7 +427,7 @@ export interface ShallowWrapper<P, S> extends CommonWrapper<P, S> {
parents<P2>(component: ComponentClass<P2>): ShallowWrapper<P2, any>;
parents<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, {}>;
parents(props: EnzymePropSelector): ShallowWrapper<any, any>;
parents(selector: string): ShallowWrapper<HTMLAttributes<{}>, any>;
parents(selector: string): ShallowWrapper<HTMLAttributes, any>;
parents(): ShallowWrapper<any, any>;

/**
Expand All @@ -438,7 +440,7 @@ export interface ShallowWrapper<P, S> extends CommonWrapper<P, S> {
closest<P2>(component: ComponentClass<P2>): ShallowWrapper<P2, any>;
closest<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, {}>;
closest(props: EnzymePropSelector): ShallowWrapper<any, any>;
closest(selector: string): ShallowWrapper<HTMLAttributes<{}>, any>;
closest(selector: string): ShallowWrapper<HTMLAttributes, any>;

/**
* Returns a wrapper with the direct parent of the node in the current wrapper.
Expand Down Expand Up @@ -482,7 +484,7 @@ export interface ReactWrapper<P, S> extends CommonWrapper<P, S> {
find<P2>(component: ComponentClass<P2>): ReactWrapper<P2, any>;
find<P2>(statelessComponent: (props: P2) => JSX.Element): ReactWrapper<P2, {}>;
find(props: EnzymePropSelector): ReactWrapper<any, any>;
find(selector: string): ReactWrapper<HTMLAttributes<{}>, any>;
find(selector: string): ReactWrapper<HTMLAttributes, any>;

/**
* Finds every node in the render tree that returns true for the provided predicate function.
Expand All @@ -497,7 +499,7 @@ export interface ReactWrapper<P, S> extends CommonWrapper<P, S> {
filter<P2>(component: ComponentClass<P2>): ReactWrapper<P2, any>;
filter<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, {}>;
filter(props: EnzymePropSelector): ReactWrapper<any, any>;
filter(selector: string): ReactWrapper<HTMLAttributes<{}>, any>;
filter(selector: string): ReactWrapper<HTMLAttributes, any>;

/**
* Returns a new wrapper with all of the children of the node(s) in the current wrapper. Optionally, a selector
Expand All @@ -507,7 +509,7 @@ export interface ReactWrapper<P, S> extends CommonWrapper<P, S> {
children<P2>(component: ComponentClass<P2>): ReactWrapper<P2, any>;
children<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, {}>;
children(props: EnzymePropSelector): ReactWrapper<any, any>;
children(selector: string): ReactWrapper<HTMLAttributes<{}>, any>;
children(selector: string): ReactWrapper<HTMLAttributes, any>;
children(): ReactWrapper<any, any>;

/**
Expand All @@ -527,7 +529,7 @@ export interface ReactWrapper<P, S> extends CommonWrapper<P, S> {
parents<P2>(component: ComponentClass<P2>): ReactWrapper<P2, any>;
parents<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, {}>;
parents(props: EnzymePropSelector): ReactWrapper<any, any>;
parents(selector: string): ReactWrapper<HTMLAttributes<{}>, any>;
parents(selector: string): ReactWrapper<HTMLAttributes, any>;
parents(): ReactWrapper<any, any>;

/**
Expand All @@ -540,7 +542,7 @@ export interface ReactWrapper<P, S> extends CommonWrapper<P, S> {
closest<P2>(component: ComponentClass<P2>): ReactWrapper<P2, any>;
closest<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, {}>;
closest(props: EnzymePropSelector): ReactWrapper<any, any>;
closest(selector: string): ReactWrapper<HTMLAttributes<{}>, any>;
closest(selector: string): ReactWrapper<HTMLAttributes, any>;

/**
* Returns a wrapper with the direct parent of the node in the current wrapper.
Expand Down

0 comments on commit 8cd8119

Please sign in to comment.