mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-18 07:51:48 +08:00
Merge pull request #14610 from asvetliakov/enzyme-update
enzyme: return any as state for shallow() and mount()
This commit is contained in:
@@ -37,6 +37,13 @@ namespace ShallowWrapperTest {
|
||||
elementWrapper: ShallowWrapper<HTMLAttributes<{}>, {}>,
|
||||
statelessWrapper: ShallowWrapper<StatelessProps, never>;
|
||||
|
||||
function test_props_state_inferring() {
|
||||
let wrapper: ShallowWrapper<MyComponentProps, MyComponentState>;
|
||||
wrapper = shallow(<MyComponent stringProp="value" />);
|
||||
wrapper.state().stateProperty;
|
||||
wrapper.props().stringProp.toUpperCase();
|
||||
}
|
||||
|
||||
function test_shallow_options() {
|
||||
shallow(<MyComponent stringProp="1"/>, {
|
||||
context: {
|
||||
@@ -337,6 +344,13 @@ namespace ReactWrapperTest {
|
||||
elementWrapper: ReactWrapper<HTMLAttributes<{}>, {}>,
|
||||
statelessWrapper: ReactWrapper<StatelessProps, never>;
|
||||
|
||||
function test_prop_state_inferring() {
|
||||
let wrapper: ReactWrapper<MyComponentProps, MyComponentState>;
|
||||
wrapper = mount(<MyComponent stringProp="value" />);
|
||||
wrapper.state().stateProperty;
|
||||
wrapper.props().stringProp.toUpperCase();
|
||||
}
|
||||
|
||||
function test_unmount() {
|
||||
reactWrapper = reactWrapper.unmount();
|
||||
}
|
||||
|
||||
2
enzyme/index.d.ts
vendored
2
enzyme/index.d.ts
vendored
@@ -546,6 +546,7 @@ export interface MountRendererProps {
|
||||
* @param node
|
||||
* @param [options]
|
||||
*/
|
||||
export function shallow<P>(node: ReactElement<P>, options?: ShallowRendererProps): ShallowWrapper<P, any>;
|
||||
export function shallow<P, S>(node: ReactElement<P>, options?: ShallowRendererProps): ShallowWrapper<P, S>;
|
||||
|
||||
/**
|
||||
@@ -553,6 +554,7 @@ export function shallow<P, S>(node: ReactElement<P>, options?: ShallowRendererPr
|
||||
* @param node
|
||||
* @param [options]
|
||||
*/
|
||||
export function mount<P>(node: ReactElement<P>, options?: MountRendererProps): ReactWrapper<P, any>;
|
||||
export function mount<P, S>(node: ReactElement<P>, options?: MountRendererProps): ReactWrapper<P, S>;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user