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 from './index.js'; const connector = createConnector(localMeta(meta)); describe('mattel-creations', () => { runFixtureSuite(connector, it, expect); it('normalises official Mattel listings with brand tag, MSRP and sold-out state', async () => { const batmobile = await connector.normalize(loadFixture('mattel-creations', 'hot-wheels-collectors-6909546856653').raw); expect(batmobile.length).toBe(1); const r = batmobile[0]!; if (r.kind !== 'listing') throw new Error('expected listing'); expect(r.attributes.categorySlug).toBe('model_cars'); expect(r.attributes.brand).toBe('Hot Wheels Collectors'); expect(r.attributes.franchise).toBe('Hot Wheels'); expect(r.attributes.identifiers.sku).toBe('HCD19'); expect(r.price).toBe(107); expect(r.attributes.originalMsrp).toBe(107); expect(r.attributes.originalMsrpCurrency).toBe('USD'); expect(r.availability).toBe('ended'); // sold out at capture time, kept for MSRP history expect(r.attributes.metadata.mattel_category).toBe('Vehicles'); const motu = await connector.normalize(loadFixture('mattel-creations', 'shop-9016606589133').raw); expect(motu[0]?.kind).toBe('listing'); if (motu[0]?.kind === 'listing') { expect(motu[0].attributes.categorySlug).toBe('action_figures'); expect(motu[0].attributes.brand).toBe('Masters of the Universe'); } for (const name of listFixtures('mattel-creations')) { for (const x of await connector.normalize(loadFixture('mattel-creations', name).raw)) { if (x.kind !== 'listing') throw new Error('expected listing'); expect(x.currency).toBe('USD'); expect(x.seller).toBe('Mattel Creations'); expect(x.condition.completeness).toBe('sealed'); expect(meta.categories).toContain(x.attributes.categorySlug); } } }); });