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, { completenessFromTitle } from './index.js'; const connector = createConnector(localMeta(meta)); describe('videogametrader', () => { runFixtureSuite(connector, it, expect); it('derives completeness/condition from the store vocabulary', () => { expect(completenessFromTitle('Tomba - Playstation - Used (Complete)', ['Condition:Used (Complete)'])).toEqual({ completeness: 'cib', conditionRaw: 'Used (Complete)' }); expect(completenessFromTitle('Metal Storm | NES - New', [])).toEqual({ completeness: 'sealed', conditionRaw: 'New' }); expect(completenessFromTitle('Super Mario 64 - Nintendo 64 - Used (Loose)', ['Condition:Used (Loose)'])).toEqual({ completeness: 'loose', conditionRaw: 'Used (Loose)' }); expect(completenessFromTitle('Some Game', [])).toEqual({ completeness: null, conditionRaw: null }); }); it('normalises Shopify products into USD listings and drops accessories', async () => { const adapter = await connector.normalize(loadFixture('videogametrader', 'nintendo-nes-games-6662420037687').raw); expect(adapter).toEqual([]); // "3 in 1 AC Adapter" → excluded by rule const cib = await connector.normalize(loadFixture('videogametrader', 'shop-7289023561783').raw); expect(cib.length).toBe(1); const r = cib[0]!; if (r.kind !== 'listing') throw new Error('expected listing'); expect(r.attributes.categorySlug).toBe('playstation_games'); expect(r.attributes.name).toBe('Alone In The Dark The New Nightmare'); expect(r.attributes.set).toBe('Playstation'); expect(r.condition.completeness).toBe('cib'); expect(r.currency).toBe('USD'); expect(r.price).toBeGreaterThan(0); expect(r.attributes.identifiers.sku).toBeTruthy(); for (const name of listFixtures('videogametrader')) { for (const x of await connector.normalize(loadFixture('videogametrader', name).raw)) { expect(x.kind).toBe('listing'); if (x.kind === 'listing') { expect(meta.categories).toContain(x.attributes.categorySlug); expect(x.seller).toBe('Video Game Trader'); } } } }); });