|
| 1 | +import { Competition } from '@wca/helpers'; |
| 2 | +import { hasMultipleScheduleLocations } from './activities'; |
| 3 | + |
| 4 | +const baseCompetition = { |
| 5 | + formatVersion: '1.0', |
| 6 | + id: 'TestComp2026', |
| 7 | + name: 'Test Comp 2026', |
| 8 | + shortName: 'Test Comp', |
| 9 | + events: [], |
| 10 | + persons: [], |
| 11 | + competitorLimit: 0, |
| 12 | + extensions: [], |
| 13 | +} as const; |
| 14 | + |
| 15 | +describe('hasMultipleScheduleLocations', () => { |
| 16 | + it('returns false for a single room without stage metadata', () => { |
| 17 | + const wcif = { |
| 18 | + ...baseCompetition, |
| 19 | + schedule: { |
| 20 | + numberOfDays: 1, |
| 21 | + startDate: '2026-03-15', |
| 22 | + venues: [ |
| 23 | + { |
| 24 | + id: 1, |
| 25 | + name: 'Venue', |
| 26 | + timezone: 'America/Los_Angeles', |
| 27 | + rooms: [ |
| 28 | + { |
| 29 | + id: 10, |
| 30 | + name: 'Main Room', |
| 31 | + color: '#123456', |
| 32 | + activities: [], |
| 33 | + extensions: [], |
| 34 | + }, |
| 35 | + ], |
| 36 | + }, |
| 37 | + ], |
| 38 | + }, |
| 39 | + } as unknown as Competition; |
| 40 | + |
| 41 | + expect(hasMultipleScheduleLocations(wcif)).toBe(false); |
| 42 | + }); |
| 43 | + |
| 44 | + it('returns true for a single room with multiple stages in the natshelper extension', () => { |
| 45 | + const wcif = { |
| 46 | + ...baseCompetition, |
| 47 | + schedule: { |
| 48 | + numberOfDays: 1, |
| 49 | + startDate: '2026-03-15', |
| 50 | + venues: [ |
| 51 | + { |
| 52 | + id: 1, |
| 53 | + name: 'Venue', |
| 54 | + timezone: 'America/Los_Angeles', |
| 55 | + rooms: [ |
| 56 | + { |
| 57 | + id: 10, |
| 58 | + name: 'Main Room', |
| 59 | + color: '#123456', |
| 60 | + activities: [], |
| 61 | + extensions: [ |
| 62 | + { |
| 63 | + id: 'org.cubingusa.natshelper.v1.Room', |
| 64 | + data: { |
| 65 | + stages: [ |
| 66 | + { id: 1, name: 'Stage A', color: '#ff0000' }, |
| 67 | + { id: 2, name: 'Stage B', color: '#00ff00' }, |
| 68 | + ], |
| 69 | + }, |
| 70 | + }, |
| 71 | + ], |
| 72 | + }, |
| 73 | + ], |
| 74 | + }, |
| 75 | + ], |
| 76 | + }, |
| 77 | + } as unknown as Competition; |
| 78 | + |
| 79 | + expect(hasMultipleScheduleLocations(wcif)).toBe(true); |
| 80 | + }); |
| 81 | +}); |
0 commit comments