feat(phase2): 타로 78장 카드 데이터 TS 포팅 + 무결성 테스트
web-ui(src/pages/tarot/data/cards.js)의 메이저 22장·마이너 56장 데이터와 buildMinor/buildMinorDetails 생성 로직을 lib/tarot/cards.ts로 값 변경 없이 포팅. TarotCard/Spread 타입 부여, SPREADS는 three_card만 유지. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
30
lib/__tests__/tarot-cards.test.ts
Normal file
30
lib/__tests__/tarot-cards.test.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { TAROT_DECK, findCard, CATEGORIES } from '../tarot/cards';
|
||||
|
||||
describe('TAROT_DECK', () => {
|
||||
it('78장이다', () => { expect(TAROT_DECK).toHaveLength(78); });
|
||||
it('slug가 고유하다', () => {
|
||||
const slugs = TAROT_DECK.map((c) => c.slug);
|
||||
expect(new Set(slugs).size).toBe(78);
|
||||
});
|
||||
it('메이저 22 + 마이너 56', () => {
|
||||
expect(TAROT_DECK.filter((c) => c.arcana === 'major')).toHaveLength(22);
|
||||
expect(TAROT_DECK.filter((c) => c.arcana === 'minor')).toHaveLength(56);
|
||||
});
|
||||
it('모든 카드에 필수 필드가 채워져 있다', () => {
|
||||
for (const c of TAROT_DECK) {
|
||||
expect(c.name.length).toBeGreaterThan(0);
|
||||
expect(c.nameEn.length).toBeGreaterThan(0);
|
||||
expect(c.keywords.length).toBeGreaterThan(0);
|
||||
expect(c.reversedKeywords.length).toBeGreaterThan(0);
|
||||
expect(c.meaningUpright.length).toBeGreaterThan(0);
|
||||
expect(c.meaningReversed.length).toBeGreaterThan(0);
|
||||
expect(c.image).toMatch(/^\/images\/tarot\/cards\/[a-z0-9-]+\.png$/);
|
||||
}
|
||||
});
|
||||
it('findCard가 slug로 카드를 찾는다', () => {
|
||||
expect(findCard('the-fool')?.nameEn).toBe('The Fool');
|
||||
expect(findCard('nonexistent')).toBeUndefined();
|
||||
});
|
||||
it('CATEGORIES는 6개', () => { expect(CATEGORIES).toHaveLength(6); });
|
||||
});
|
||||
Reference in New Issue
Block a user