score:1
You have to get the function from the childs prop and call it. As it returns a promise you need to use async/await or return the promise from your test, have a look at docs for more infos. Then test the state of the rendered component.
it("should update item accordingly", async() => {
const rendered = shallow(React.createElement(Item));
await rendered.find('someChild).prop('updateItem')('someId')
expect(item.state).toEqual({
item: {blah:'blah'}
})
})
Source: stackoverflow.com
Related Query
- Get updated state of component when calling method on class via enzyme
- When calling a method in a react class component from a react functional component, is the state visible?
- How to test React state after calling a component method that updates state - using Enzyme
- how to auto refresh component when redux state get updated
- How to get updated redux-toolkit state when component is not re-render
- state in parent component is not updated when method fire from child component
- State no updating in class component when testing method with jest
- How to get updated ID from array when calling set state in React
- Accessing the State of a Functional Component with React Hooks when Testing with Enzyme
- Access prop outside of class in React when calling Higher Order Component
- State not updated when setState is called from tinyMCE onAction method
- React component function returning JSX causes error when used in render method of ES6 class React component
- How to get React/recompose component updated when props are changed?
- How do I correctly spyOn a react component's method via the class prototype or the enzyme wrapper instance?
- Port redux state to component state when the component mounts (without need for GET request)
- Get url params in ReactJS when using class component
- Why React component get re-rendered only once when state does not change?
- When Redux state changes all components get updated values EXCEPT one
- React Component not updated when state changes
- Which React cycle method should I use to re-render component when redux state has changed?
- browser says " request has been blocked by CORS policy" when calling to a spring boot get method from react js using axios
- How to re-rendering react class component when state is changed
- react, get updated state after dispatch in functional component
- setting react state when clicking on a functional component via onClick (TypeScript)
- Redux how to get updated store state in root component
- How to get updated state from Redux store using redux-toolkit after component has already rendered?
- Functional component definition inside class component's render() method, state resets when created through JSX, but not when called directly
- Toggling a CSS class when a React.js component gets updated
- React component not re-rendering when "Date" in state gets updated
- Invalid hook call in class component when I try to use useParams to get the param from url
More Query from same tag
- How to specify the label name of the last elements of a tree in D3.js?
- How to to emit/fire event from hooks
- Chat Box UI not scrolling with react-bootstrap Accordion
- Interference in data retrieval
- How to control react-bootstrap carousel with custom buttons?
- Sending POST request with body in axios
- How to call a function in a Reusable component in React
- Filtering by categories react and bootstrap
- Search Filter from json file data in React
- Access parent element from different component?
- How to handle save states in React/Flux?
- Javascript clearInterval with interval Id doesn't work in react js
- How to display a line in 3s plane on map?
- undefined error when trying to set state
- componentDidMount called BEFORE ref callback
- React: How to implement Component.SubComponent
- Writing optimized React functional components
- React: Update array entry with button click
- Using Promise when extracting data from Supabase into React
- Navigate/select ag-grid table row with arrow keys
- react-slideshow-image package not loading images from google drive
- component doesn't update after state update
- Link tag inside BrowserRouter changes only the URL, but doesn't render the component
- Trouble updating boolean value with save() using mongoose
- Multiple Nested Routes in react-router-dom v4
- React-router-dom v4 not rendering component on page load
- React Countup trigger start when state is true
- css-loader localIdentName: is a hash necessary for uniqueness?
- Assign className conditionally based on source object property
- sending data in correct format from react to node