SPB Git forge

spb/rareindex

Public
54commits 1branches 0releases
7.1 MBsize
maindefault branch
10 days agolast push
TypeScript 61.9% HTML 37.2% SQL 0.7%
1.6 KB · 32 lines typescript
Raw Blame History
1import { describe, expect, it } from 'vitest';2import { getConnectorMeta } from '@rareindex/connectors';3import { loadFixture, runFixtureSuite } from '@rareindex/connectors/testing';4import createConnector from './index.js';56const connector = createConnector(getConnectorMeta('tcgdex'));78describe('tcgdex', () => {9  runFixtureSuite(connector, it, expect);1011  it('aligns Base Set cards with the pokemontcg vocabulary and dates prices by their update time', async () => {12    const out = await connector.normalize(loadFixture('tcgdex', 'en-base1-1').raw);13    const cat = out.find((r) => r.kind === 'catalog_item');14    if (cat?.kind !== 'catalog_item') throw new Error('no catalog item');15    expect(cat.attributes.categorySlug).toBe('pokemon');16    expect(cat.attributes.setCode).toBe('BS');17    expect(cat.attributes.number).toBe('1');18    expect(cat.attributes.name).toBe('Alakazam');19    expect(cat.attributes.variant).toBe('Holo');20    expect(cat.attributes.language).toBe('English');21    expect(cat.attributes.identifiers.pokemontcg_id).toBe('base1-1');22    expect(cat.attributes.identifiers.tcgplayer_id).toMatch(/^\d+$/);23    const obs = out.filter((r) => r.kind === 'price_observation');24    expect(obs.length).toBeGreaterThan(3);25    const usd = obs.find((o) => o.kind === 'price_observation' && o.currency === 'USD' && o.priceKind === 'market');26    const eur = obs.find((o) => o.kind === 'price_observation' && o.currency === 'EUR' && o.priceKind === 'trend');27    expect(usd).toBeTruthy();28    expect(eur).toBeTruthy();29    if (usd?.kind === 'price_observation') expect(usd.observationDate.getTime()).toBeLessThan(usd.observedAt.getTime() + 1);30  });31});32