The code I want to test is:
const handleChecked = (event: React.SyntheticEvent): void => {
const { name } = event.currentTarget as HTMLInputElement;
const id = +name;
dispatch(checkUncheckCustomer(id));
};
Current test:
it('should check/uncheck customer', () => {
const customer = wrapper
.find('.customersList .list li')
.first()
.find('.checkbox-custom');
customer.simulate('click');
const dispatch = jest.fn(useDispatch);
const id = mockCustomersList[0].id;
expect(dispatch).toHaveBeenCalledTimes(1);
expect(dispatch).toHaveBeenCalledWith(checkUncheckCustomer(id));
});
And it works in the app, but in test I get:
Expected number of calls: 1
Received number of calls: 0
Aucun commentaire:
Enregistrer un commentaire