-
Notifications
You must be signed in to change notification settings - Fork 276
Closed
Labels
questionFurther information is requestedFurther information is requested
Description
I need to have a unit test which checks whether my component dropdown handler function has been invoked after pressing any elements in the dropdown.
The error that I am getting is that the handler function is not being invoked.
I've tried using the waitfor. Didnt make any difference.
Test:
it("render NewDatePicker and check on Press", async () => {
const mockCurrentFn = jest.fn();
render(<NewDatePicker placeholder="Test Placeholder" mode="time"
setValue={mockCurrentFn} testId="test" value={undefined} />)
fireEvent.press(await screen.findByTestId("test"));
fireEvent.press(await screen.findByText("Confirm Date"));
await waitFor(() => {
expect(mockCurrentFn).toHaveBeenCalled();
})
});
Component:
The relevant portion where I call the handle function.
const handleConfirmDate = () => {
setValue(selectedDate);
handleAnimationClose();
};
<CustomButton
buttonStyle={defaultButtonStyle}
onPress={handleConfirmDate}
text={buttonText || DATE_PICKER.BUTTON_CONFIRM}
/>
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested