import assert from 'node:assert/strict'; import test from 'node:test'; import type { MatchParticipantView } from '@lolympus/contracts'; import { getHistoryMatchTitle, getHomeMatchEnrollment, getHomeMatchSchedule, getNextMatchBanner, } from '../src/pages/home-match-presentation.ts'; test('uses the Korean schedule and only removes a matching generic title prefix', () => { const schedule = getHomeMatchSchedule('2026-06-25T12:00:00.000Z'); assert.equal(schedule?.compact, '6/25 (목) 21:00'); assert.equal( getHistoryMatchTitle('6/25 (목) 21시 정기 내전', schedule), '정기 내전', ); for (const title of [ '6/25 (목) 21시 멸망전', '6/25 (목) 20시 내전', '6/24 (수) 21시 내전', ]) { assert.equal(getHistoryMatchTitle(title, schedule), title); } }); test('promotes application only for an open match with available places', () => { const match = { status: 'recruiting' as const, joined: false, maxParticipants: 4, participants: [], }; assert.deepEqual(getHomeMatchEnrollment(match), { canApply: true, capacity: '0/4명', label: '4자리 남음', }); assert.deepEqual(getHomeMatchEnrollment({ ...match, maxParticipants: 0 }), { canApply: false, capacity: '0명', label: '모집 마감', }); assert.equal( getHomeMatchEnrollment({ ...match, status: 'team-built' }).canApply, false, ); assert.equal( getHomeMatchEnrollment({ ...match, joined: true }).label, '참가 완료', ); }); test('uses neutral titles and distinguishes registration states on the next match banner', () => { const match = { title: '토요일 내전', status: 'recruiting' as const, joined: false, maxParticipants: 1, participants: [], }; const participant: MatchParticipantView = { userId: 'player-1' as MatchParticipantView['userId'], joinedAt: '2026-11-10T09:00:00.000Z', preferredPositions: [], excluded: false, }; assert.deepEqual(getNextMatchBanner(match), { title: '정기 내전', status: '모집 중', capacity: '0/1명', canApply: true, }); const fullMatch = { ...match, participants: [participant] }; assert.equal(getNextMatchBanner(fullMatch).status, '정원 마감'); assert.equal(getNextMatchBanner({ ...fullMatch, joined: true }).status, '신청 완료'); assert.equal(getNextMatchBanner({ ...match, maxParticipants: 0 }).status, '모집 마감'); assert.deepEqual( getNextMatchBanner({ ...fullMatch, title: '토요일 시즌 결승 내전', status: 'team-built' }), { title: '토요일 시즌 결승 내전', status: '팀 편성', capacity: '1/1명', canApply: false }, ); });