- {/* Stats Sidebar */}
-
-
-
- Statistics
-
-
-
-
- Total Cards:
-
- {stats.totalCards}
-
-
-
- Avg. CMC:
-
- {stats.avgCmc}
-
-
-
- Format:
-
- {deck.format}
-
-
-
-
- {/* Color Distribution */}
- {Object.keys(stats.colorCounts).length > 0 && (
-
-
- Color Distribution
-
-
- {Object.entries(stats.colorCounts)
- .sort(([, a], [, b]) => b - a)
- .map(([color, count]) => (
-
-
- {color}
-
- {color}
-
-
-
- {count}
-
-
- ))}
-
-
- )}
-
- {/* Type Distribution */}
- {Object.keys(stats.typeCounts).length > 0 && (
-
-
- Card Types
-
-
- {Object.entries(stats.typeCounts)
- .sort(([, a], [, b]) => b - a)
- .slice(0, 8)
- .map(([type, count]) => (
-
-
- {type}
-
-
- {count}
-
-
- ))}
-
-
- )}
-
-
- {/* Group By Controls */}
-
-
- Group Cards By
-
-
- {[
- { value: 'type', label: 'Card Type' },
- { value: 'cmc', label: 'Mana Cost' },
- { value: 'color', label: 'Color' },
- { value: 'rarity', label: 'Rarity' },
- ].map(option => (
-
- ))}
-
-
-
+
{/* Card List */}
diff --git a/test/lib/deck-detail-grouping.test.js b/test/lib/deck-detail-grouping.test.js
new file mode 100644
index 0000000..5945f24
--- /dev/null
+++ b/test/lib/deck-detail-grouping.test.js
@@ -0,0 +1,37 @@
+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);
+ });
+});