mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 15:27:05 +00:00
Merge pull request #33187 from screendriver/enzyme
[enzyme] Add renderProp() function
This commit is contained in:
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/producthunt/chai-enzyme
|
||||
// Definitions by: Alexey Svetliakov <https://github.com/asvetliakov>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
// TypeScript Version: 3.1
|
||||
|
||||
|
||||
/// <reference types="enzyme" />
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/commercetools/enzyme-extensions
|
||||
// Definitions by: Christian Rackerseder <https://github.com/screendriver>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
// TypeScript Version: 3.1
|
||||
|
||||
import * as enzyme from 'enzyme';
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: http://airbnb.io/enzyme/
|
||||
// Definitions by: Nabeelah Ali <https://github.com/nali>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
// TypeScript Version: 3.1
|
||||
|
||||
import { EnzymeAdapter } from 'enzyme';
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/airbnb/enzyme, http://airbnb.io/enzyme
|
||||
// Definitions by: Tanguy Krotoff <https://github.com/tkrotoff>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
// TypeScript Version: 3.1
|
||||
|
||||
import { EnzymeAdapter } from 'enzyme';
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/airbnb/enzyme, http://airbnb.io/enzyme
|
||||
// Definitions by: Tanguy Krotoff <https://github.com/tkrotoff>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
// TypeScript Version: 3.1
|
||||
|
||||
import { EnzymeAdapter } from 'enzyme';
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/zth/enzyme-async-helpers
|
||||
// Definitions by: Kim Ehrenpohl <https://github.com/kimehrenpohl>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
// TypeScript Version: 3.1
|
||||
|
||||
import { ReactWrapper, EnzymeSelector } from 'enzyme';
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/Knegusen/enzyme-redux#readme
|
||||
// Definitions by: Dennis Axelsson <https://github.com/knegusen>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
// TypeScript Version: 3.1
|
||||
|
||||
import { ReactWrapper, ShallowWrapper } from 'enzyme';
|
||||
import { ReactElement } from 'react';
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/adriantoine/enzyme-to-json#readme
|
||||
// Definitions by: Joscha Feth <https://github.com/joscha>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
// TypeScript Version: 3.1
|
||||
|
||||
import { ReactWrapper, ShallowWrapper } from 'enzyme';
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
ShallowRendererProps,
|
||||
ComponentClass as EnzymeComponentClass
|
||||
} from "enzyme";
|
||||
import { Component, ReactElement, HTMLAttributes, ComponentClass, StatelessComponent } from "react";
|
||||
import { Component, ReactElement, ReactNode, HTMLAttributes, ComponentClass, StatelessComponent } from "react";
|
||||
|
||||
// Help classes/interfaces
|
||||
interface MyComponentProps {
|
||||
@@ -35,6 +35,10 @@ interface MyComponentState {
|
||||
stateProperty: string;
|
||||
}
|
||||
|
||||
interface MyRenderPropProps {
|
||||
children: (params: string) => ReactNode;
|
||||
}
|
||||
|
||||
function toComponentType<T>(Component: ComponentClass<T> | StatelessComponent<T>): ComponentClass<T> | StatelessComponent<T> {
|
||||
return Component;
|
||||
}
|
||||
@@ -59,6 +63,8 @@ class AnotherComponent extends Component<AnotherComponentProps> {
|
||||
}
|
||||
}
|
||||
|
||||
class MyRenderPropComponent extends Component<MyRenderPropProps> {}
|
||||
|
||||
const MyStatelessComponent = (props: StatelessProps) => <span />;
|
||||
|
||||
const AnotherStatelessComponent = (props: AnotherStatelessProps) => <span />;
|
||||
@@ -477,6 +483,11 @@ function ShallowWrapperTest() {
|
||||
shallowWrapper = new ShallowWrapper<MyComponentProps, MyComponentState>(<MyComponent stringProp="1" numberProp={1} />, undefined, { lifecycleExperimental: true });
|
||||
shallowWrapper = new ShallowWrapper<MyComponentProps, MyComponentState>(<MyComponent stringProp="1" numberProp={1} />, shallowWrapper, { lifecycleExperimental: true });
|
||||
}
|
||||
|
||||
function test_renderProp() {
|
||||
let shallowWrapper = new ShallowWrapper<MyRenderPropProps>(<MyRenderPropComponent children={(params) => <div className={params} />} />);
|
||||
shallowWrapper = shallowWrapper.renderProp('children')('test');
|
||||
}
|
||||
}
|
||||
|
||||
// ReactWrapper
|
||||
|
||||
Vendored
+10
-2
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Enzyme 3.1
|
||||
// Type definitions for Enzyme 3.9
|
||||
// Project: https://github.com/airbnb/enzyme
|
||||
// Definitions by: Marian Palkus <https://github.com/MarianPalkus>
|
||||
// Cap3 <http://www.cap3.de>
|
||||
@@ -8,8 +8,9 @@
|
||||
// MartynasZilinskas <https://github.com/MartynasZilinskas>
|
||||
// Torgeir Hovden <https://github.com/thovden>
|
||||
// Martin Hochel <https://github.com/hotell>
|
||||
// Christian Rackerseder <https://github.com/screendriver>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
// TypeScript Version: 3.1
|
||||
|
||||
/// <reference types="cheerio" />
|
||||
import { ReactElement, Component, AllHTMLAttributes as ReactHTMLAttributes, SVGAttributes as ReactSVGAttributes } from "react";
|
||||
@@ -363,6 +364,8 @@ export interface CommonWrapper<P = {}, S = {}, C = Component<P, S>> {
|
||||
length: number;
|
||||
}
|
||||
|
||||
export type Parameters<T> = T extends (...args: infer A) => any ? A : never;
|
||||
|
||||
// tslint:disable-next-line no-empty-interface
|
||||
export interface ShallowWrapper<P = {}, S = {}, C = Component> extends CommonWrapper<P, S, C> { }
|
||||
export class ShallowWrapper<P = {}, S = {}, C = Component> {
|
||||
@@ -447,6 +450,11 @@ export class ShallowWrapper<P = {}, S = {}, C = Component> {
|
||||
* Returns a wrapper with the direct parent of the node in the current wrapper.
|
||||
*/
|
||||
parent(): ShallowWrapper<any, any>;
|
||||
|
||||
/**
|
||||
* Returns a wrapper of the node rendered by the provided render prop.
|
||||
*/
|
||||
renderProp<PropName extends keyof P>(prop: PropName): (...params: Parameters<P[PropName]>) => ShallowWrapper<any, never>;
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-empty-interface
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/formidablelabs/enzyme-matchers/packages/jasmine-enzyme
|
||||
// Definitions by: Umar Bolatov <https://github.com/bolatovumar>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
// TypeScript Version: 3.1
|
||||
|
||||
/// <reference types="jasmine" />
|
||||
/// <reference types="react" />
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/igor-dv/jest-specific-snapshot#readme
|
||||
// Definitions by: Janeene Beeforth <https://github.com/dawnmist>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.0
|
||||
// TypeScript Version: 3.1
|
||||
|
||||
/// <reference types="jest" />
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/storybooks/storybook/tree/master/addons/storyshots, https://github.com/storybooks/storybook/tree/master/addons/storyshorts/storyshots-core
|
||||
// Definitions by: Bradley Ayers <https://github.com/bradleyayers>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.0
|
||||
// TypeScript Version: 3.1
|
||||
|
||||
import * as React from 'react';
|
||||
import { StoryObject } from '@storybook/react';
|
||||
|
||||
Reference in New Issue
Block a user