Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

@types/enzyme

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/enzyme - npm Package Compare versions

Comparing version 2.7.3 to 2.7.4

219

enzyme/index.d.ts

@@ -1,8 +0,9 @@

// Type definitions for Enzyme v2.7.0
// Type definitions for Enzyme 2.7
// Project: https://github.com/airbnb/enzyme
// Definitions by: Marian Palkus <https://github.com/MarianPalkus>, Cap3 <http://www.cap3.de>, Ivo Stratev <https://github.com/NoHomey>, Tom Crockett <https://github.com/pelotom>
// Definitions by: Marian Palkus <https://github.com/MarianPalkus>, Cap3 <http://www.cap3.de>, Ivo Stratev <https://github.com/NoHomey>, Tom Crockett <https://github.com/pelotom>, jwbay <https://githb.com/jwbay>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
import { ReactElement, Component, StatelessComponent, ComponentClass, HTMLAttributes as ReactHTMLAttributes, SVGAttributes as ReactSVGAttributes } from "react";
/// <reference types="cheerio" />
import { ReactElement, Component, HTMLAttributes as ReactHTMLAttributes, SVGAttributes as ReactSVGAttributes } from "react";

@@ -14,2 +15,12 @@ type HTMLAttributes = ReactHTMLAttributes<{}> & ReactSVGAttributes<{}>;

/* These are purposefully stripped down versions of React.ComponentClass and React.StatelessComponent.
* The optional static properties on them break overload ordering for wrapper methods if they're not
* all specified in the implementation. TS chooses the EnzymePropSelector overload and loses the generics
*/
interface ComponentClass<Props> {
new(props?: Props, context?: any): Component<Props, any>;
}
type StatelessComponent<Props> = (props: Props, context?: any) => JSX.Element;
/**

@@ -25,31 +36,9 @@ * Many methods in Enzyme's API accept a selector as an argument. Selectors in Enzyme can fall into one of the

*/
export type EnzymeSelector = string | StatelessComponent<any> | ComponentClass<any> | { [key: string]: any };
export type EnzymePropSelector = { [key: string]: any };
export interface EnzymePropSelector {
[key: string]: any;
}
export type EnzymeSelector = string | StatelessComponent<any> | ComponentClass<any> | EnzymePropSelector;
interface CommonWrapper<P, S> {
/**
* Find every node in the render tree that matches the provided selector.
* @param selector The selector to match.
*/
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>;
/**
* Finds every node in the render tree that returns true for the provided predicate function.
* @param predicate
*/
findWhere(predicate: (wrapper: CommonWrapper<any, any>) => boolean): CommonWrapper<any, any>;
/**
* Removes nodes in the current wrapper that do not match the provided selector.
* @param selector The selector to match.
*/
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>;
/**
* Returns a new wrapper with only the nodes of the current wrapper that, when passed into the provided predicate function, return true.

@@ -76,3 +65,3 @@ * @param predicate

*/
containsAllMatchingElements(nodes: ReactElement<any>[]): boolean;
containsAllMatchingElements(nodes: Array<ReactElement<any>>): boolean;

@@ -83,3 +72,3 @@ /**

*/
containsAnyMatchingElements(nodes: ReactElement<any>[]): boolean;
containsAnyMatchingElements(nodes: Array<ReactElement<any>>): boolean;

@@ -126,50 +115,2 @@ /**

/**
* Returns a new wrapper with all of the children of the node(s) in the current wrapper. Optionally, a selector
* can be provided and it will filter the children by this selector.
* @param [selector]
*/
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(): CommonWrapper<any, any>;
/**
* Returns a new wrapper with child at the specified index.
* @param index
*/
childAt(index: number): CommonWrapper<any, any>;
childAt<P2, S2>(index: number): CommonWrapper<P2, S2>;
/**
* Returns a wrapper around all of the parents/ancestors of the wrapper. Does not include the node in the
* current wrapper. Optionally, a selector can be provided and it will filter the parents by this selector.
*
* Note: can only be called on a wrapper of a single node.
* @param [selector]
*/
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(): CommonWrapper<any, any>;
/**
* Returns a wrapper with the direct parent of the node in the current wrapper.
*/
parent(): CommonWrapper<any, any>;
/**
* Returns a wrapper of the first element that matches the selector by traversing up through the current node's
* ancestors in the tree, starting with itself.
*
* Note: can only be called on a wrapper of a single node.
* @param selector
*/
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>;
/**
* Returns a string of the rendered text of the current render tree. This function should be looked at with

@@ -217,3 +158,3 @@ * skepticism if being used to test what the actual HTML output of the component will be. If that is what you

state(): S;
state(key: string): any;
state<K extends keyof S>(key: K): S[K];
state<T>(key: string): T;

@@ -224,4 +165,4 @@

*/
context(key?: string): any;
context<T>(key?: string): T;
context(): any;
context<T>(key: string): T;

@@ -241,3 +182,3 @@ /**

*/
prop(key: string): any;
prop<K extends keyof P>(key: K): P[K];
prop<T>(key: string): T;

@@ -271,3 +212,3 @@

*/
setState(state: S, callback?: () => void): this;
setState<K extends keyof S>(state: Pick<S, K>, callback?: () => void): this;

@@ -286,3 +227,3 @@ /**

*/
setProps(props: P, callback?: () => void): this;
setProps<K extends keyof P>(props: Pick<P, K>): this;

@@ -297,3 +238,3 @@ /**

*/
setContext(context: Object): this;
setContext(context: any): this;

@@ -323,10 +264,2 @@ /**

/**
* Returns the type of the current node of this wrapper. If it's a composite component, this will be the
* component constructor. If it's native DOM node, it will be a string of the tag name.
*
* Note: can only be called on a wrapper of a single node.
*/
type(): string | Function;
/**
* Returns the name of the current node of the wrapper.

@@ -396,2 +329,20 @@ */

/**
* Returns true if renderer returned null
*/
isEmptyRender(): boolean;
/**
* Renders the component to static markup and returns a Cheerio wrapper around the result.
*/
render(): Cheerio;
/**
* Returns the type of the current node of this wrapper. If it's a composite component, this will be the
* component constructor. If it's native DOM node, it will be a string of the tag name.
*
* Note: can only be called on a wrapper of a single node.
*/
type(): string | ComponentClass<P> | StatelessComponent<P> ;
length: number;

@@ -402,3 +353,2 @@ }

shallow(): ShallowWrapper<P, S>;
render(): CheerioWrapper<P, S>;
unmount(): ShallowWrapper<any, any>;

@@ -411,3 +361,3 @@

find<P2>(component: ComponentClass<P2>): ShallowWrapper<P2, any>;
find<P2>(statelessComponent: (props: P2) => JSX.Element): ShallowWrapper<P2, {}>;
find<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, never>;
find(props: EnzymePropSelector): ShallowWrapper<any, any>;

@@ -420,6 +370,5 @@ find(selector: string): ShallowWrapper<HTMLAttributes, any>;

*/
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<P2>(component: ComponentClass<P2> | StatelessComponent<P2>): this;
filter(props: Partial<P>): this;
filter(selector: string): this;

@@ -430,3 +379,3 @@ /**

*/
findWhere(predicate: (wrapper: CommonWrapper<any, any>) => boolean): ShallowWrapper<any, any>;
findWhere(predicate: (wrapper: ShallowWrapper<any, any>) => boolean): ShallowWrapper<any, any>;

@@ -439,6 +388,5 @@ /**

children<P2>(component: ComponentClass<P2>): ShallowWrapper<P2, any>;
children<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, {}>;
children(props: EnzymePropSelector): ShallowWrapper<any, any>;
children<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, never>;
children(selector: string): ShallowWrapper<HTMLAttributes, any>;
children(): ShallowWrapper<any, any>;
children(props?: EnzymePropSelector): ShallowWrapper<any, any>;

@@ -453,9 +401,9 @@ /**

/**
* Shallow render the one non-DOM child of the current wrapper, and return a wrapper around the result.
* NOTE: can only be called on wrapper of a single non-DOM component element node.
* @param [options]
*/
dive<P2, S2>(options?: ShallowRendererProps): ShallowWrapper<P2, S2>;
* Shallow render the one non-DOM child of the current wrapper, and return a wrapper around the result.
* NOTE: can only be called on wrapper of a single non-DOM component element node.
* @param [options]
*/
dive<P2, S2>(options?: ShallowRendererProps): ShallowWrapper<P2, S2>;
/**
/**
* Returns a wrapper around all of the parents/ancestors of the wrapper. Does not include the node in the

@@ -468,6 +416,5 @@ * current wrapper. Optionally, a selector can be provided and it will filter the parents by this selector.

parents<P2>(component: ComponentClass<P2>): ShallowWrapper<P2, any>;
parents<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, {}>;
parents(props: EnzymePropSelector): ShallowWrapper<any, any>;
parents<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, never>;
parents(selector: string): ShallowWrapper<HTMLAttributes, any>;
parents(): ShallowWrapper<any, any>;
parents(props?: EnzymePropSelector): ShallowWrapper<any, any>;

@@ -482,3 +429,3 @@ /**

closest<P2>(component: ComponentClass<P2>): ShallowWrapper<P2, any>;
closest<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, {}>;
closest<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, never>;
closest(props: EnzymePropSelector): ShallowWrapper<any, any>;

@@ -491,7 +438,2 @@ closest(selector: string): ShallowWrapper<HTMLAttributes, any>;

parent(): ShallowWrapper<any, any>;
/**
* Returns true if renderer returned null
*/
isEmptyRender(): boolean;
}

@@ -502,3 +444,2 @@

mount(): ReactWrapper<any, any>;
render(): CheerioWrapper<P, S>;

@@ -529,3 +470,3 @@ /**

find<P2>(component: ComponentClass<P2>): ReactWrapper<P2, any>;
find<P2>(statelessComponent: (props: P2) => JSX.Element): ReactWrapper<P2, {}>;
find<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, never>;
find(props: EnzymePropSelector): ReactWrapper<any, any>;

@@ -538,3 +479,3 @@ find(selector: string): ReactWrapper<HTMLAttributes, any>;

*/
findWhere(predicate: (wrapper: CommonWrapper<any, any>) => boolean): ReactWrapper<any, any>;
findWhere(predicate: (wrapper: ReactWrapper<any, any>) => boolean): ReactWrapper<any, any>;

@@ -545,6 +486,5 @@ /**

*/
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<P2>(component: ComponentClass<P2> | StatelessComponent<P2>): this;
filter(props: Partial<P>): this;
filter(selector: string): this;

@@ -557,6 +497,5 @@ /**

children<P2>(component: ComponentClass<P2>): ReactWrapper<P2, any>;
children<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, {}>;
children(props: EnzymePropSelector): ReactWrapper<any, any>;
children<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, never>;
children(selector: string): ReactWrapper<HTMLAttributes, any>;
children(): ReactWrapper<any, any>;
children(props?: EnzymePropSelector): ReactWrapper<any, any>;

@@ -578,6 +517,5 @@ /**

parents<P2>(component: ComponentClass<P2>): ReactWrapper<P2, any>;
parents<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, {}>;
parents(props: EnzymePropSelector): ReactWrapper<any, any>;
parents<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, never>;
parents(selector: string): ReactWrapper<HTMLAttributes, any>;
parents(): ReactWrapper<any, any>;
parents(props?: EnzymePropSelector): ReactWrapper<any, any>;

@@ -592,3 +530,3 @@ /**

closest<P2>(component: ComponentClass<P2>): ReactWrapper<P2, any>;
closest<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, {}>;
closest<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, never>;
closest(props: EnzymePropSelector): ReactWrapper<any, any>;

@@ -601,13 +539,4 @@ closest(selector: string): ReactWrapper<HTMLAttributes, any>;

parent(): ReactWrapper<any, any>;
/**
* Returns true if renderer returned null
*/
isEmptyRender(): boolean;
}
export interface CheerioWrapper<P, S> extends CommonWrapper<P, S> {
}
export interface ShallowRendererProps {

@@ -659,6 +588,2 @@ /**

*/
export function render<P, S>(node: ReactElement<P>, options?: any): CheerioWrapper<P, S>;
export function describeWithDOM(description: string, fn: Function): void;
export function spyLifecycle(component: typeof Component): void;
export function render<P, S>(node: ReactElement<P>, options?: any): Cheerio;
{
"name": "@types/enzyme",
"version": "2.7.3",
"version": "2.7.4",
"description": "TypeScript definitions for Enzyme",
"license": "MIT",
"author": "Marian Palkus <https://github.com/MarianPalkus>, Cap3 <http://www.cap3.de>, Ivo Stratev <https://github.com/NoHomey>, Tom Crockett <https://github.com/pelotom>",
"author": "Marian Palkus <https://github.com/MarianPalkus>, Cap3 <http://www.cap3.de>, Ivo Stratev <https://github.com/NoHomey>, Tom Crockett <https://github.com/pelotom>, jwbay <https://githb.com/jwbay>",
"main": "",

@@ -14,7 +14,8 @@ "repository": {

"dependencies": {
"@types/react": "*"
"@types/react": "*",
"@types/cheerio": "*"
},
"peerDependencies": {},
"typesPublisherContentHash": "c608e96dd83df6fb0592e0148e22168a8cb268d352bb6217c531b96e2c36b3ec",
"typesPublisherContentHash": "e59c997fab2d00f834e3aefd6b6e7c7cc8f424ab6b9596276902df5605156ed7",
"typeScriptVersion": "2.1"
}

@@ -11,7 +11,7 @@ # Installation

Additional Details
* Last updated: Tue, 07 Feb 2017 20:01:00 GMT
* Dependencies: react
* Last updated: Tue, 07 Feb 2017 23:24:43 GMT
* Dependencies: react, cheerio
* Global values: none
# Credits
These definitions were written by Marian Palkus <https://github.com/MarianPalkus>, Cap3 <http://www.cap3.de>, Ivo Stratev <https://github.com/NoHomey>, Tom Crockett <https://github.com/pelotom>.
These definitions were written by Marian Palkus <https://github.com/MarianPalkus>, Cap3 <http://www.cap3.de>, Ivo Stratev <https://github.com/NoHomey>, Tom Crockett <https://github.com/pelotom>, jwbay <https://githb.com/jwbay>.

@@ -6,5 +6,6 @@ {

"data": {
"authors": "Marian Palkus <https://github.com/MarianPalkus>, Cap3 <http://www.cap3.de>, Ivo Stratev <https://github.com/NoHomey>, Tom Crockett <https://github.com/pelotom>",
"authors": "Marian Palkus <https://github.com/MarianPalkus>, Cap3 <http://www.cap3.de>, Ivo Stratev <https://github.com/NoHomey>, Tom Crockett <https://github.com/pelotom>, jwbay <https://githb.com/jwbay>",
"dependencies": {
"react": "*"
"react": "*",
"cheerio": "*"
},

@@ -27,5 +28,5 @@ "pathMappings": {},

"hasPackageJson": false,
"contentHash": "c608e96dd83df6fb0592e0148e22168a8cb268d352bb6217c531b96e2c36b3ec"
"contentHash": "e59c997fab2d00f834e3aefd6b6e7c7cc8f424ab6b9596276902df5605156ed7"
},
"isLatest": true
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc