Reuse computeDeckStats from deck-builder-stats; add groupDeckCards lib, DeckDetailStatsSidebar component, and vitest coverage. Fixes stray semicolon after useEffect. Page drops ~205 lines. Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
import { describe, it, expect } from 'vitest';
|
|
import { groupDeckCards } from '../../lib/deck-detail-grouping.js';
|
|
import { getDeckFormatIcon } from '../../lib/deck-format-utils.js';
|
|
|
|
describe('getDeckFormatIcon', () => {
|
|
it('returns emoji for known formats', () => {
|
|
expect(getDeckFormatIcon('Commander')).toBe('⚔️');
|
|
expect(getDeckFormatIcon('Standard')).toBe('🏆');
|
|
});
|
|
|
|
it('returns default for unknown format', () => {
|
|
expect(getDeckFormatIcon('Pioneer')).toBe('🃏');
|
|
});
|
|
});
|
|
|
|
describe('groupDeckCards', () => {
|
|
const cards = [
|
|
{ name: 'Bolt', card_type: 'Instant', cmc: 1, colors: '["R"]', rarity: 'common', quantity: 4 },
|
|
{ name: 'Giant', card_type: 'Creature — Giant', cmc: 5, colors: '["R","G"]', rarity: 'rare', quantity: 1 },
|
|
];
|
|
|
|
it('returns empty object when cards is undefined', () => {
|
|
expect(groupDeckCards(undefined, 'type')).toEqual({});
|
|
});
|
|
|
|
it('groups by card type prefix', () => {
|
|
const groups = groupDeckCards(cards, 'type');
|
|
expect(groups.Instant).toHaveLength(1);
|
|
expect(groups.Creature).toHaveLength(1);
|
|
});
|
|
|
|
it('groups by cmc', () => {
|
|
const groups = groupDeckCards(cards, 'cmc');
|
|
expect(groups['1 Mana']).toHaveLength(1);
|
|
expect(groups['5 Mana']).toHaveLength(1);
|
|
});
|
|
});
|