fix(frontend): prevent RangeError in TimeAdjuster and add validation to SleepButton
Build Frontend / build (push) Failing after 3m15s
Build Frontend / build (push) Failing after 3m15s
This commit is contained in:
@@ -70,4 +70,20 @@ describe('SleepButton', () => {
|
||||
|
||||
await waitFor(() => expect(endSessionMock).toHaveBeenCalled());
|
||||
});
|
||||
|
||||
it('shows alert when time is invalid', async () => {
|
||||
const alertSpy = vi.spyOn(window, 'alert').mockImplementation(() => {});
|
||||
(useSleepSession as any).mockReturnValue({
|
||||
activeSession: null,
|
||||
isCreating: false,
|
||||
isEnding: false,
|
||||
});
|
||||
|
||||
renderWithProviders(<SleepButton time="" />);
|
||||
const button = screen.getByRole('button', { name: /Start Sleep/i });
|
||||
fireEvent.click(button);
|
||||
|
||||
expect(alertSpy).toHaveBeenCalledWith('Please select a valid time.');
|
||||
alertSpy.mockRestore();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user