我要测试的代码是:
dict.entry(&String::from(key))
当前测试:
const handleChecked = (event: React.SyntheticEvent): void => {
const { name } = event.currentTarget as HTMLInputElement;
const id = +name;
dispatch(checkUncheckCustomer(id));
};
它在应用程序中有效,但在测试中我得到:
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));
});