Fisher-Yates 셔플, 카드 픽 생성, 참고 블록/메타데이터 빌더 구현. Task 4(interpret API)·Task 6(UI)에서 소비됨. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
21 lines
790 B
TypeScript
21 lines
790 B
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { fisherYates, buildShuffle } from '../tarot/shuffle';
|
|
import { TAROT_DECK } from '../tarot/cards';
|
|
|
|
describe('fisherYates', () => {
|
|
it('원본을 변형하지 않고 같은 원소 집합을 반환한다', () => {
|
|
const input = [1, 2, 3, 4, 5];
|
|
const out = fisherYates(input);
|
|
expect(input).toEqual([1, 2, 3, 4, 5]);
|
|
expect([...out].sort()).toEqual([1, 2, 3, 4, 5]);
|
|
});
|
|
});
|
|
describe('buildShuffle', () => {
|
|
it('요청한 수만큼, 중복 없이, reversed 필드를 갖고 반환한다', () => {
|
|
const out = buildShuffle(TAROT_DECK, 20);
|
|
expect(out).toHaveLength(20);
|
|
expect(new Set(out.map((c) => c.slug)).size).toBe(20);
|
|
for (const c of out) expect(typeof c.reversed).toBe('boolean');
|
|
});
|
|
});
|