I think your test almost works fine but you need to replace two things.
Since you're manually calling getItems
here you could create a mock Component that would ideally do similar stuff as the components you plan to use with your HOC.
For example, this mock component coould have a button that when clicked would call getItems
and would also display items
.
const MockComponent = ({items, getItems}) => {
return (
<div>
<button data-testid="button" onClick={getItems}>Click me</button>
<ul>
{ items.map((item, index) => <li key={index}>{item}</li>) }
</ul>
</div>
)
Then in your test instead of manually calling getItems
:
const res = await wrapper.props().getItems();
you could do something like
fireEvent.click(getByTestId('button')
and then assert that your tagsApi was called and that your component displays correct items.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…