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%
2.1 KB · 43 lines typescript
Raw Blame History
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 from './index.js';67const connector = createConnector(localMeta(meta));89describe('mattel-creations', () => {10  runFixtureSuite(connector, it, expect);1112  it('normalises official Mattel listings with brand tag, MSRP and sold-out state', async () => {13    const batmobile = await connector.normalize(loadFixture('mattel-creations', 'hot-wheels-collectors-6909546856653').raw);14    expect(batmobile.length).toBe(1);15    const r = batmobile[0]!;16    if (r.kind !== 'listing') throw new Error('expected listing');17    expect(r.attributes.categorySlug).toBe('model_cars');18    expect(r.attributes.brand).toBe('Hot Wheels Collectors');19    expect(r.attributes.franchise).toBe('Hot Wheels');20    expect(r.attributes.identifiers.sku).toBe('HCD19');21    expect(r.price).toBe(107);22    expect(r.attributes.originalMsrp).toBe(107);23    expect(r.attributes.originalMsrpCurrency).toBe('USD');24    expect(r.availability).toBe('ended'); // sold out at capture time, kept for MSRP history25    expect(r.attributes.metadata.mattel_category).toBe('Vehicles');26    const motu = await connector.normalize(loadFixture('mattel-creations', 'shop-9016606589133').raw);27    expect(motu[0]?.kind).toBe('listing');28    if (motu[0]?.kind === 'listing') {29      expect(motu[0].attributes.categorySlug).toBe('action_figures');30      expect(motu[0].attributes.brand).toBe('Masters of the Universe');31    }32    for (const name of listFixtures('mattel-creations')) {33      for (const x of await connector.normalize(loadFixture('mattel-creations', name).raw)) {34        if (x.kind !== 'listing') throw new Error('expected listing');35        expect(x.currency).toBe('USD');36        expect(x.seller).toBe('Mattel Creations');37        expect(x.condition.completeness).toBe('sealed');38        expect(meta.categories).toContain(x.attributes.categorySlug);39      }40    }41  });42});43