- apps/server: Hono API(auth/me/config/admin), Bun WebSocket(welcome·ping/pong, 압축 끔), SQLite 마이그레이션 - 사이트 설정: 채팅 도배 방지 기본 꺼짐(관리자가 켬, 초당·순간 횟수) - apps/web: 첫 화면·로그인·관리자(대시보드·사이트·사용자·관리자·기록), 라이트/다크, 휴대폰, noindex - packages/shared: 닉네임 규칙, 프로토콜(zod), 시계 차이 계산 - 테스트 20개 + 브라우저 e2e 6단계 통과 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
23 lines
949 B
TypeScript
23 lines
949 B
TypeScript
import { expect, test } from 'bun:test';
|
|
import { clockOffset, nicknameError, normalizeNickname, suggestNickname } from './index';
|
|
|
|
test('nickname rules', () => {
|
|
expect(nicknameError(normalizeNickname(' 사금향 '))).toBeNull();
|
|
expect(nicknameError('a')).not.toBeNull();
|
|
expect(nicknameError('열세글자가넘는아주긴닉네임이에요')).not.toBeNull();
|
|
expect(nicknameError('씨 발')).not.toBeNull();
|
|
for (let i = 0; i < 50; i++) expect(nicknameError(suggestNickname())).toBeNull();
|
|
});
|
|
|
|
test('clock offset uses the sample with the smallest round trip', () => {
|
|
// client clock is 1000ms behind the server; the second sample has a 10ms round trip.
|
|
const r = clockOffset([
|
|
{ sent: 0, received: 200, server: 1150 },
|
|
{ sent: 500, received: 510, server: 1505 },
|
|
{ sent: 900, received: 1100, server: 1950 },
|
|
])!;
|
|
expect(r.rtt).toBe(10);
|
|
expect(r.offset).toBe(1000);
|
|
expect(clockOffset([])).toBeNull();
|
|
});
|