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('tcgdex')); describe('tcgdex', () => { runFixtureSuite(connector, it, expect); it('aligns Base Set cards with the pokemontcg vocabulary and dates prices by their update time', async () => { const out = await connector.normalize(loadFixture('tcgdex', 'en-base1-1').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('pokemon'); expect(cat.attributes.setCode).toBe('BS'); expect(cat.attributes.number).toBe('1'); expect(cat.attributes.name).toBe('Alakazam'); expect(cat.attributes.variant).toBe('Holo'); expect(cat.attributes.language).toBe('English'); expect(cat.attributes.identifiers.pokemontcg_id).toBe('base1-1'); expect(cat.attributes.identifiers.tcgplayer_id).toMatch(/^\d+$/); const obs = out.filter((r) => r.kind === 'price_observation'); expect(obs.length).toBeGreaterThan(3); const usd = obs.find((o) => o.kind === 'price_observation' && o.currency === 'USD' && o.priceKind === 'market'); const eur = obs.find((o) => o.kind === 'price_observation' && o.currency === 'EUR' && o.priceKind === 'trend'); expect(usd).toBeTruthy(); expect(eur).toBeTruthy(); if (usd?.kind === 'price_observation') expect(usd.observationDate.getTime()).toBeLessThan(usd.observedAt.getTime() + 1); }); });