diff --git a/enzyme/enzyme-tests.tsx b/enzyme/enzyme-tests.tsx index ff23b91445..e5d56200cb 100644 --- a/enzyme/enzyme-tests.tsx +++ b/enzyme/enzyme-tests.tsx @@ -96,6 +96,18 @@ namespace ShallowWrapperTest { boolVal = shallowWrapper.containsAnyMatchingElements([
]); } + function test_dive() { + interface TmpProps { + foo: any + } + + interface TmpState { + bar: any + } + + const diveWrapper: ShallowWrapper = shallowWrapper.dive({ context: { foobar: 'barfoo' }}); + } + function test_equals() { boolVal = shallowWrapper.equals(
); } @@ -222,11 +234,11 @@ namespace ShallowWrapperTest { } function test_setState() { - shallowWrapper = shallowWrapper.setState({ stateProperty: 'state' }); + shallowWrapper = shallowWrapper.setState({ stateProperty: 'state' }, () => console.log('state updated')); } function test_setProps() { - shallowWrapper = shallowWrapper.setProps({ propsProperty: 'foo' }); + shallowWrapper = shallowWrapper.setProps({ propsProperty: 'foo' }, () => console.log('props updated')); } function test_setContext() { diff --git a/enzyme/enzyme.d.ts b/enzyme/enzyme.d.ts index b94b7b9f9f..5a53f8bf20 100644 --- a/enzyme/enzyme.d.ts +++ b/enzyme/enzyme.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Enzyme v2.4.1 +// Type definitions for Enzyme v2.5.1 // Project: https://github.com/airbnb/enzyme -// Definitions by: Marian Palkus , Cap3 +// Definitions by: Marian Palkus , Cap3 , Ivo Stratev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -253,8 +253,9 @@ declare module "enzyme" { * * NOTE: can only be called on a wrapper instance that is also the root instance. * @param state + * @param [callback] */ - setState(state: S): this; + setState(state: S, callback?: () => void): this; /** * A method that sets the props of the root component, and re-renders. Useful for when you are wanting to test @@ -265,9 +266,10 @@ declare module "enzyme" { * Returns itself. * * NOTE: can only be called on a wrapper instance that is also the root instance. - * @param state + * @param props + * @param [callback] */ - setProps(props: P): this; + setProps(props: P, callback?: () => void): this; /** * A method that sets the context of the root component, and re-renders. Useful for when you are wanting to @@ -424,6 +426,13 @@ declare module "enzyme" { childAt(index: number): ShallowWrapper; childAt(index: number): ShallowWrapper; + /** + * 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(options?: ShallowRendererProps): ShallowWrapper; + /** * 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.