feat: redesign match play and add broadcast tooling
This commit is contained in:
29
src/lib/availability.test.ts
Normal file
29
src/lib/availability.test.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { describe, expect, test } from 'vitest';
|
||||
import { hoursToRanges, rangesToHours, isTimezone } from './availability';
|
||||
|
||||
describe('availability', () => {
|
||||
test('round trips split windows and midnight', () => {
|
||||
const hours = [0, 1, 9, 10, 18, 19, 20, 22, 23];
|
||||
expect(rangesToHours(hoursToRanges(hours))).toEqual(hours);
|
||||
});
|
||||
test('supports an overnight range and deduplicates overlaps', () => {
|
||||
expect(
|
||||
rangesToHours([
|
||||
{ start: '22:00', end: '02:00' },
|
||||
{ start: '23:00', end: '01:00' }
|
||||
])
|
||||
).toEqual([0, 1, 22, 23]);
|
||||
});
|
||||
test('no ranges means no preference', () => {
|
||||
expect(rangesToHours([])).toEqual([]);
|
||||
});
|
||||
test('rejects malformed times and ambiguous full-day ranges', () => {
|
||||
for (const start of ['18:30', '24:00', '-1:00', 'abc', '18:00'])
|
||||
expect(() => rangesToHours([{ start, end: '18:00' }])).toThrow();
|
||||
});
|
||||
test('validates IANA time zones', () => {
|
||||
expect(isTimezone('Europe/Amsterdam')).toBe(true);
|
||||
expect(isTimezone('UTC')).toBe(true);
|
||||
expect(isTimezone('Mars/Olympus')).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user