feat: release version 1.0.5
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createInitialReleaseClock, synchronizeReleaseClock } from '../data/release-clock.ts';
|
||||
|
||||
test('서버 시각은 시스템 시각 변경과 무관하게 단조 시계로 흐른다', async () => {
|
||||
let monotonic = 100;
|
||||
let wall = 9_999_999;
|
||||
const clock = await synchronizeReleaseClock({
|
||||
fetcher: async () => {
|
||||
monotonic = 140;
|
||||
return { ok: true, json: async () => ({ now: 1_000 }) } as Response;
|
||||
},
|
||||
wallNow: () => wall,
|
||||
monotonicNow: () => monotonic,
|
||||
online: true
|
||||
});
|
||||
|
||||
assert.equal(clock.source, 'server');
|
||||
assert.equal(clock.now(), 1_020);
|
||||
wall = 1;
|
||||
monotonic = 240;
|
||||
assert.equal(clock.now(), 1_120);
|
||||
});
|
||||
|
||||
test('오프라인에서는 요청하지 않고 현재 시스템 시각을 사용한다', async () => {
|
||||
let wall = 2_000;
|
||||
let requested = false;
|
||||
const clock = await synchronizeReleaseClock({
|
||||
fetcher: async () => {
|
||||
requested = true;
|
||||
throw new Error('호출되면 안 됨');
|
||||
},
|
||||
wallNow: () => wall,
|
||||
online: false
|
||||
});
|
||||
|
||||
assert.equal(requested, false);
|
||||
assert.equal(clock.source, 'system');
|
||||
assert.equal(clock.now(), 2_000);
|
||||
wall = 3_000;
|
||||
assert.equal(clock.now(), 3_000);
|
||||
});
|
||||
|
||||
test('온라인 시각 요청 실패 시에만 시스템 시각으로 대체한다', async () => {
|
||||
const clock = await synchronizeReleaseClock({
|
||||
fetcher: async () => { throw new Error('offline'); },
|
||||
wallNow: () => 4_000,
|
||||
online: true
|
||||
});
|
||||
assert.equal(clock.source, 'system');
|
||||
assert.equal(clock.now(), 4_000);
|
||||
});
|
||||
|
||||
test('초기 서버 시각도 시스템 시각 대신 단조 시계로 진행한다', () => {
|
||||
let monotonic = 10;
|
||||
const clock = createInitialReleaseClock(5_000, {
|
||||
wallNow: () => 99_999,
|
||||
monotonicNow: () => monotonic
|
||||
});
|
||||
monotonic = 35;
|
||||
assert.equal(clock.source, 'server');
|
||||
assert.equal(clock.now(), 5_025);
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { isSongReleased, releasedSongCharts, SONG_RELEASE_TIMES } from '../data/song-release.ts';
|
||||
|
||||
test('신규 악곡 공개 시각을 HolodoriDB의 한국 시각과 일치시킨다', () => {
|
||||
assert.deepEqual(SONG_RELEASE_TIMES, {
|
||||
m0332: Date.parse('2026-08-19T20:00:00+09:00'),
|
||||
m0353: Date.parse('2026-08-20T00:00:00+09:00'),
|
||||
m0335: Date.parse('2026-08-21T20:00:00+09:00'),
|
||||
m0333: Date.parse('2026-08-23T20:00:00+09:00'),
|
||||
m0336: Date.parse('2026-08-25T20:00:00+09:00')
|
||||
});
|
||||
});
|
||||
|
||||
test('공개 시각 전에는 신규 악곡을 숨기고 공개 시각부터 표시한다', () => {
|
||||
const releaseTime = SONG_RELEASE_TIMES.m0332;
|
||||
|
||||
assert.equal(isSongReleased('m0332', releaseTime - 1), false);
|
||||
assert.equal(isSongReleased('m0332', releaseTime), true);
|
||||
assert.equal(isSongReleased('existing-song', releaseTime - 1), true);
|
||||
});
|
||||
|
||||
test('채보 목록에서 공개되지 않은 악곡의 모든 난이도를 제외한다', () => {
|
||||
const charts = [
|
||||
{ songId: 'existing-song', difficulty: 'expert' },
|
||||
{ songId: 'm0332', difficulty: 'expert' },
|
||||
{ songId: 'm0332', difficulty: 'hard' }
|
||||
];
|
||||
|
||||
assert.deepEqual(releasedSongCharts(charts, SONG_RELEASE_TIMES.m0332 - 1), [charts[0]]);
|
||||
assert.deepEqual(releasedSongCharts(charts, SONG_RELEASE_TIMES.m0332), charts);
|
||||
});
|
||||
Reference in New Issue
Block a user