27 lines
1.4 KiB
TypeScript
27 lines
1.4 KiB
TypeScript
import { expect, test } from 'bun:test';
|
|
import { applyAction, setupGame, usersOf } from '../help-kit.test-util';
|
|
import { GAMES } from '@bg/games';
|
|
import { helpNow } from './help';
|
|
|
|
const users = usersOf(['A', 'B']);
|
|
const view = (s: unknown, who: string | null) => GAMES.omok!.view(s, who) as any;
|
|
|
|
test('오목: 내 차례 / 상대 차례 / 관전 / 첫 수 가운데', () => {
|
|
const { state } = setupGame('omok', 2, { colorAssignment: 'hostBlack', ruleSet: 'renju' });
|
|
expect(helpNow(view(state, 'A'), 'A', users)).toContain('첫 수는 판 한가운데');
|
|
expect(helpNow(view(state, 'B'), 'B', users)).toContain('상대(호랑이님) 차례예요');
|
|
expect(helpNow(view(state, null), null, users)).toContain('호랑이님(흑) 차례예요');
|
|
const s2 = applyAction('omok', state, 'A', { type: 'place', x: 7, y: 7 });
|
|
const t = helpNow(view(s2, 'B'), 'B', users);
|
|
expect(t).toContain('내 차례예요(백)');
|
|
expect(t).toContain('5개');
|
|
});
|
|
|
|
test('오목: 무르기 요청을 받으면 수락/거절 안내', () => {
|
|
const { state } = setupGame('omok', 2, { colorAssignment: 'hostBlack', ruleSet: 'free' });
|
|
let s = applyAction('omok', state, 'A', { type: 'place', x: 7, y: 7 });
|
|
s = applyAction('omok', s, 'A', { type: 'requestUndo' });
|
|
expect(helpNow(view(s, 'B'), 'B', users)).toContain('[수락]');
|
|
expect(helpNow(view(s, 'A'), 'A', users)).toContain('무르기 요청');
|
|
});
|