import { describe, expect, it } from 'vitest'; import meta from './meta.json' with { type: 'json' }; import { localMeta } from '../_lib/local-meta.js'; import { listFixtures, loadFixture, runFixtureSuite } from '@rareindex/connectors/testing'; import createConnector, { primarySet, setPrefix } from './index.js'; const connector = createConnector(localMeta(meta)); describe('digimoncard', () => { runFixtureSuite(connector, it, expect); it('derives the primary set from the card number prefix', () => { expect(setPrefix('BT5-103')).toEqual({ prefix: 'BT5', code: 'BT-05' }); expect(setPrefix('ST1-03').code).toBe('ST-1'); expect(primarySet('BT5-103', ['Promo', 'BT-05: Battle of Omni'])).toBe('BT-05: Battle of Omni'); expect(primarySet('ST1-03', ['ST-1: Starter Deck Gaia Red', 'Trial Deck'])).toBe('ST-1: Starter Deck Gaia Red'); }); it('emits digimon_tcg catalog items with tcgplayer ids when present', async () => { const [name] = listFixtures('digimoncard'); const out = await connector.normalize(loadFixture('digimoncard', name!).raw); expect(out).toHaveLength(1); const c = out[0]!; if (c.kind !== 'catalog_item') throw new Error('expected catalog item'); expect(c.attributes.categorySlug).toBe('digimon_tcg'); expect(c.attributes.identifiers.digimoncard_id).toMatch(/^[A-Z]+\d*-\d+$/); expect(c.imageUrls[0]).toContain('images.digimoncard.io'); }); });