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:
@@ -12,6 +12,7 @@ import {
|
||||
adjustForTimezone,
|
||||
getLocalOffsetFromReference,
|
||||
formatDateTime,
|
||||
toUTCFromLocalInput,
|
||||
} from '../../src/utils/time';
|
||||
|
||||
describe('formatMinutesAfter', () => {
|
||||
@@ -152,3 +153,18 @@ describe('getLocalOffsetFromReference', () => {
|
||||
expect(offset).toBe(localMins - refMins);
|
||||
});
|
||||
});
|
||||
|
||||
describe('toUTCFromLocalInput', () => {
|
||||
it('converts valid datetime-local string to ISO UTC string', () => {
|
||||
const input = '2024-01-15T10:00';
|
||||
// This is tricky because it depends on local timezone.
|
||||
// But we just want to see if it works for a valid input.
|
||||
const result = toUTCFromLocalInput(input);
|
||||
expect(result).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/);
|
||||
});
|
||||
|
||||
it('returns empty string on invalid datetime-local string', () => {
|
||||
expect(toUTCFromLocalInput('2026-06-0')).toBe('');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user