import { describe, expect, it } from 'vitest'; import { getConnectorMeta } from '@rareindex/connectors'; import { loadFixture, runFixtureSuite } from '@rareindex/connectors/testing'; import createConnector from './index.js'; const connector = createConnector(getConnectorMeta('sportscardspro')); describe('sportscardspro', () => { runFixtureSuite(connector, it, expect); it('maps a 1986 Fleer Jordan page to a sports card asset with graded and raw sales', async () => { const fx = loadFixture('sportscardspro', 'basketball-1986-fleer__michael-jordan-57'); const out = await connector.normalize(fx.raw); const cat = out.find((r) => r.kind === 'catalog_item'); if (cat?.kind !== 'catalog_item') throw new Error('no catalog item'); expect(cat.attributes.categorySlug).toBe('basketball_cards'); expect(cat.attributes.set).toBe('1986 Fleer'); expect(cat.attributes.year).toBe(1986); expect(cat.attributes.number).toBe('57'); expect(cat.attributes.name).toBe('Michael Jordan'); expect(cat.attributes.brand).toBe('Fleer'); expect(cat.attributes.variant).toBeNull(); // "[Rookie]" is a status tag, not a printing expect(cat.attributes.metadata.rookie).toBe(true); expect(cat.attributes.identifiers.pricecharting_id).toMatch(/^scp:\d+$/); const guides = out.filter((r) => r.kind === 'price_observation'); expect(guides.length).toBeGreaterThanOrEqual(10); const psa10 = guides.find((g) => g.kind === 'price_observation' && g.grade.grader === 'psa' && g.grade.grade === '10'); expect(psa10).toBeTruthy(); const sales = out.filter((r) => r.kind === 'sale'); expect(sales.length).toBeGreaterThan(10); const graded = sales.filter((s) => s.kind === 'sale' && s.grade.grade !== null); expect(graded.length).toBeGreaterThan(0); for (const s of sales) if (s.kind === 'sale') expect(s.currency).toBe('USD'); }); });