feat: redesign match play and add broadcast tooling

This commit is contained in:
2026-09-29 02:52:56 +00:00
parent f417a831f7
commit 9b9aafefc1
348 changed files with 31588 additions and 11094 deletions

View 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);
});
});