diff --git a/packages/react/src/components/TimePicker/TimePicker-test.js b/packages/react/src/components/TimePicker/TimePicker-test.js index 8844e9ffa172..eaf36abaf409 100644 --- a/packages/react/src/components/TimePicker/TimePicker-test.js +++ b/packages/react/src/components/TimePicker/TimePicker-test.js @@ -90,6 +90,39 @@ describe('TimePicker', () => { render(); expect(screen.getByPlaceholderText('🧸')).toBeInTheDocument(); }); + + it('should call onBlur when not disabled or readOnly', () => { + const onBlur = jest.fn(); + render(); + const input = screen.getByRole('textbox'); + + fireEvent.blur(input); + expect(onBlur).toHaveBeenCalled(); + }); + + it('should not call onBlur when disabled', () => { + const onBlur = jest.fn(); + render(); + const input = screen.getByRole('textbox'); + + fireEvent.blur(input); + expect(onBlur).not.toHaveBeenCalled(); + }); + + it('should update value and prevValue when value changes', () => { + const { rerender } = render( + + ); + + // Initial render + expect(screen.getByRole('textbox')).toHaveValue('10:00'); + + // Rerender with a new value + rerender(); + + // Check if the value is updated + expect(screen.getByRole('textbox')).toHaveValue('11:00'); + }); }); describe('label', () => {