import { describe, expect, it } from 'vitest'; import { getConnectorMeta } from '@rareindex/connectors'; import { listFixtures, loadFixture, runFixtureSuite } from '@rareindex/connectors/testing'; import createConnector from './index.js'; const connector = createConnector(getConnectorMeta('optcg')); describe('optcg', () => { runFixtureSuite(connector, it, expect); it('maps a Romance Dawn card with market/low prices dated by date_scraped', async () => { const [name] = listFixtures('optcg'); const fx = loadFixture('optcg', name!); 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('one_piece_card_game'); expect(cat.attributes.setCode).toBe('OP-01'); expect(cat.attributes.set).toBe('Romance Dawn'); expect(cat.attributes.number).toMatch(/^OP01-\d{3}$/); expect(cat.attributes.identifiers.optcg_id).toBe(cat.attributes.number); const obs = out.filter((r) => r.kind === 'price_observation'); expect(obs.length).toBeGreaterThanOrEqual(1); const market = obs.find((o) => o.kind === 'price_observation' && o.priceKind === 'market'); if (market?.kind === 'price_observation') { expect(market.currency).toBe('USD'); expect(market.observationDate.getTime()).toBeLessThanOrEqual(fx.raw.fetchedAt.getTime()); } }); });