51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import {
|
|
getHistoryMatchTitle,
|
|
getHomeMatchEnrollment,
|
|
getHomeMatchSchedule,
|
|
} 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,
|
|
'참가 완료',
|
|
);
|
|
});
|