diff --git a/types/enzyme/enzyme-tests.tsx b/types/enzyme/enzyme-tests.tsx index a0a25e4c39..4547101fbd 100644 --- a/types/enzyme/enzyme-tests.tsx +++ b/types/enzyme/enzyme-tests.tsx @@ -382,11 +382,13 @@ function ShallowWrapperTest() { } function test_setState() { + shallowWrapper = shallowWrapper.setState({ stateProperty: 'state' }); shallowWrapper = shallowWrapper.setState({ stateProperty: 'state' }, () => console.log('state updated')); } function test_setProps() { shallowWrapper = shallowWrapper.setProps({ stringProp: 'foo' }); + shallowWrapper = shallowWrapper.setProps({ stringProp: 'foo' }, () => console.log('props update')); } function test_setContext() { @@ -782,10 +784,12 @@ function ReactWrapperTest() { function test_setState() { reactWrapper = reactWrapper.setState({ stateProperty: 'state' }); + reactWrapper = reactWrapper.setState({ stateProperty: 'state' }, () => console.log('state set')); } function test_setProps() { - reactWrapper = reactWrapper.setProps({ stringProp: 'foo' }, () => { }); + reactWrapper = reactWrapper.setProps({ stringProp: 'foo' }); + reactWrapper = reactWrapper.setProps({ stringProp: 'foo' }, () => console.log('props set')); } function test_setContext() { diff --git a/types/enzyme/index.d.ts b/types/enzyme/index.d.ts index 0a89b9a6a2..00cc1652b3 100644 --- a/types/enzyme/index.d.ts +++ b/types/enzyme/index.d.ts @@ -10,6 +10,7 @@ // Martin Hochel // Christian Rackerseder // Mateusz SokoĊ‚a +// Braiden Cutforth // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.1 @@ -254,7 +255,7 @@ export interface CommonWrapper

> { * * NOTE: can only be called on a wrapper instance that is also the root instance. */ - setProps(props: Pick): this; + setProps(props: Pick, callback?: () => void): this; /** * A method that sets the context of the root component, and re-renders. Useful for when you are wanting to @@ -557,18 +558,6 @@ export class ReactWrapper

{ * Returns a wrapper with the direct parent of the node in the current wrapper. */ parent(): ReactWrapper; - - /** - * A method that sets the props of the root component, and re-renders. Useful for when you are wanting to test - * how the component behaves over time with changing props. Calling this, for instance, will call the - * componentWillReceiveProps lifecycle method. - * - * Similar to setState, this method accepts a props object and will merge it in with the already existing props. - * Returns itself. - * - * NOTE: can only be called on a wrapper instance that is also the root instance. - */ - setProps(props: Pick, callback?: () => void): this; } export interface ShallowRendererProps {