TypeScript 61.9%
HTML 37.2%
SQL 0.7%
1import { describe, expect, it } from 'vitest';2import meta from './meta.json' with { type: 'json' };3import { localMeta } from '../_lib/local-meta.js';4import { listFixtures, loadFixture, runFixtureSuite } from '@rareindex/connectors/testing';5import createConnector, { completenessFromTitle } from './index.js';67const connector = createConnector(localMeta(meta));89describe('videogametrader', () => {10 runFixtureSuite(connector, it, expect);1112 it('derives completeness/condition from the store vocabulary', () => {13 expect(completenessFromTitle('Tomba - Playstation - Used (Complete)', ['Condition:Used (Complete)'])).toEqual({ completeness: 'cib', conditionRaw: 'Used (Complete)' });14 expect(completenessFromTitle('Metal Storm | NES - New', [])).toEqual({ completeness: 'sealed', conditionRaw: 'New' });15 expect(completenessFromTitle('Super Mario 64 - Nintendo 64 - Used (Loose)', ['Condition:Used (Loose)'])).toEqual({ completeness: 'loose', conditionRaw: 'Used (Loose)' });16 expect(completenessFromTitle('Some Game', [])).toEqual({ completeness: null, conditionRaw: null });17 });1819 it('normalises Shopify products into USD listings and drops accessories', async () => {20 const adapter = await connector.normalize(loadFixture('videogametrader', 'nintendo-nes-games-6662420037687').raw);21 expect(adapter).toEqual([]); // "3 in 1 AC Adapter" → excluded by rule22 const cib = await connector.normalize(loadFixture('videogametrader', 'shop-7289023561783').raw);23 expect(cib.length).toBe(1);24 const r = cib[0]!;25 if (r.kind !== 'listing') throw new Error('expected listing');26 expect(r.attributes.categorySlug).toBe('playstation_games');27 expect(r.attributes.name).toBe('Alone In The Dark The New Nightmare');28 expect(r.attributes.set).toBe('Playstation');29 expect(r.condition.completeness).toBe('cib');30 expect(r.currency).toBe('USD');31 expect(r.price).toBeGreaterThan(0);32 expect(r.attributes.identifiers.sku).toBeTruthy();33 for (const name of listFixtures('videogametrader')) {34 for (const x of await connector.normalize(loadFixture('videogametrader', name).raw)) {35 expect(x.kind).toBe('listing');36 if (x.kind === 'listing') {37 expect(meta.categories).toContain(x.attributes.categorySlug);38 expect(x.seller).toBe('Video Game Trader');39 }40 }41 }42 });43});44