import { describe, expect, it } from 'vitest'; import { mapCard } from '../../../lib/card-import/bulk-sync.js'; describe('mapCard', () => { it('maps Scryfall usd to current_price and usd_foil to market_price', () => { const mapped = mapCard({ id: 'abc-123', oracle_id: 'oracle-1', name: 'Lightning Bolt', set_name: 'Alpha', set: 'lea', collector_number: '161', rarity: 'common', prices: { usd: '1.50', usd_foil: '12.00', }, }); expect(mapped.currentPrice).toBe(1.5); expect(mapped.marketPrice).toBe(12); expect(mapped.scryfallId).toBe('abc-123'); }); it('leaves prices null when Scryfall omits price fields', () => { const mapped = mapCard({ id: 'no-price', name: 'Unknown Card', set_name: 'Test', set: 'tst', collector_number: '1', rarity: 'common', prices: {}, }); expect(mapped.currentPrice).toBeNull(); expect(mapped.marketPrice).toBeNull(); }); it('parses only nonfoil price when foil is absent', () => { const mapped = mapCard({ id: 'nonfoil-only', name: 'Island', set_name: 'Test', set: 'tst', collector_number: '2', rarity: 'common', prices: { usd: '0.25' }, }); expect(mapped.currentPrice).toBe(0.25); expect(mapped.marketPrice).toBeNull(); }); });