重构
This commit is contained in:
41
apps/api/src/shared/match-time.spec.ts
Normal file
41
apps/api/src/shared/match-time.spec.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import {
|
||||
formatLocalMatchDateTime,
|
||||
isAfterLocalToday,
|
||||
isInLocalToday,
|
||||
isoToPlatformPickerDateTime,
|
||||
platformPickerDateTimeToIso,
|
||||
} from '@thebet365/shared';
|
||||
|
||||
describe('match time helpers', () => {
|
||||
it('converts Malaysia picker time to UTC ISO and back', () => {
|
||||
const iso = platformPickerDateTimeToIso('2026-06-11T19:00:00');
|
||||
|
||||
expect(iso).toBe('2026-06-11T11:00:00.000Z');
|
||||
expect(isoToPlatformPickerDateTime(iso)).toBe('2026-06-11T19:00:00');
|
||||
});
|
||||
|
||||
it('formats the same kickoff in different local time zones with GMT offsets', () => {
|
||||
const malaysia = formatLocalMatchDateTime('2026-06-11T11:00:00.000Z', 'en-US', {
|
||||
variant: 'full',
|
||||
timeZone: 'Asia/Kuala_Lumpur',
|
||||
});
|
||||
|
||||
const newYork = formatLocalMatchDateTime('2026-06-11T11:00:00.000Z', 'en-US', {
|
||||
variant: 'full',
|
||||
timeZone: 'America/New_York',
|
||||
});
|
||||
|
||||
expect(malaysia).toContain('07:00');
|
||||
expect(malaysia).toContain('GMT+8');
|
||||
expect(newYork).toContain('07:00');
|
||||
expect(newYork).toContain('GMT-4');
|
||||
expect(malaysia).not.toBe(newYork);
|
||||
});
|
||||
|
||||
it('uses the player local day for today and early buckets', () => {
|
||||
const now = new Date('2026-06-11T15:00:00-04:00');
|
||||
|
||||
expect(isInLocalToday('2026-06-12T02:00:00.000Z', now, 'America/New_York')).toBe(true);
|
||||
expect(isAfterLocalToday('2026-06-12T05:00:00.000Z', now, 'America/New_York')).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user