TypeScript 61.9%
HTML 37.2%
SQL 0.7%
1import { describe, expect, it } from 'vitest';2import { getConnectorMeta } from '@rareindex/connectors';3import { listFixtures, loadFixture, runFixtureSuite } from '@rareindex/connectors/testing';4import createConnector from './index.js';56const connector = createConnector(getConnectorMeta('optcg'));78describe('optcg', () => {9 runFixtureSuite(connector, it, expect);1011 it('maps a Romance Dawn card with market/low prices dated by date_scraped', async () => {12 const [name] = listFixtures('optcg');13 const fx = loadFixture('optcg', name!);14 const out = await connector.normalize(fx.raw);15 const cat = out.find((r) => r.kind === 'catalog_item');16 if (cat?.kind !== 'catalog_item') throw new Error('no catalog item');17 expect(cat.attributes.categorySlug).toBe('one_piece_card_game');18 expect(cat.attributes.setCode).toBe('OP-01');19 expect(cat.attributes.set).toBe('Romance Dawn');20 expect(cat.attributes.number).toMatch(/^OP01-\d{3}$/);21 expect(cat.attributes.identifiers.optcg_id).toBe(cat.attributes.number);22 const obs = out.filter((r) => r.kind === 'price_observation');23 expect(obs.length).toBeGreaterThanOrEqual(1);24 const market = obs.find((o) => o.kind === 'price_observation' && o.priceKind === 'market');25 if (market?.kind === 'price_observation') {26 expect(market.currency).toBe('USD');27 expect(market.observationDate.getTime()).toBeLessThanOrEqual(fx.raw.fetchedAt.getTime());28 }29 });30});31