deckhearth/test/lib/card-import/bulk-sync.test.js
Randall Stillwell d0468015eb
Some checks failed
CI / Lint (pull_request) Has been cancelled
CI / Schema map up to date (pull_request) Has been cancelled
CI / Forbidden patterns (9 checks) (pull_request) Has been cancelled
CI / Migrations apply (node-pg-migrate) (pull_request) Has been cancelled
Visual diff / Should run? (pull_request) Has been cancelled
CI / Unit tests (vitest) (pull_request) Has been cancelled
Convoy metrics gate / Require role-event telemetry on convoy PRs (pull_request) Has been cancelled
PR Health rollup / Aggregate gate status (pull_request) Has been cancelled
Preview smoke / Should run? (pull_request) Has been cancelled
Preview smoke / Playwright smoke (pull_request) Has been cancelled
Visual diff / Screenshot diff (pull_request) Has been cancelled
feat(pricing): convoy for online prices and local stores
Add pricing schema, free API integrations (MTG bulk, TCGdex, Foolio),
valuation and sort-by-price, card detail pricing UI, and nearby store
discovery via home zip and OSM geo clients.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-08 22:47:46 -05:00

55 lines
1.4 KiB
JavaScript

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();
});
});