mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-13 05:20:25 +00:00
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();
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -541,14 +541,14 @@ export interface MountRendererProps {
|
||||
* @param node
|
||||
* @param [options]
|
||||
*/
|
||||
export function shallow<P, S>(node: ReactElement<P>, options?: ShallowRendererProps): ShallowWrapper<P, S>;
|
||||
export function shallow<P, S>(node: ReactElement<P>, options?: ShallowRendererProps): ShallowWrapper<P, any>;
|
||||
|
||||
/**
|
||||
* Mounts and renders a react component into the document and provides a testing wrapper around it.
|
||||
* @param node
|
||||
* @param [options]
|
||||
*/
|
||||
export function mount<P, S>(node: ReactElement<P>, options?: MountRendererProps): ReactWrapper<P, S>;
|
||||
export function mount<P, S>(node: ReactElement<P>, options?: MountRendererProps): ReactWrapper<P, any>;
|
||||
|
||||
/**
|
||||
* Render react components to static HTML and analyze the resulting HTML structure.
|
||||
|
||||
Reference in New Issue
Block a user