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 · 36 lines typescript
Raw Blame History
1import { describe, expect, it } from 'vitest';2import { ConnectorMetaSchema } from '@rareindex/connectors';3import metaJson from './meta.json' with { type: 'json' };4import { loadFixture, runFixtureSuite } from '@rareindex/connectors/testing';5import createConnector from './index.js';67const connector = createConnector(ConnectorMetaSchema.parse(metaJson));89describe('lego-shop', () => {10  runFixtureSuite(connector, it, expect);1112  it('emits official MSRP catalog items and store listings keyed by set number', async () => {13    const fx = loadFixture('lego-shop', 'star-wars-theme-p1');14    const out = await connector.normalize(fx.raw);15    const cats = out.filter((r) => r.kind === 'catalog_item');16    const lst = out.filter((r) => r.kind === 'listing');17    expect(cats.length).toBeGreaterThanOrEqual(4);18    expect(lst.length).toBeGreaterThanOrEqual(4);19    for (const c of cats) {20      if (c.kind !== 'catalog_item') continue;21      expect(c.attributes.categorySlug).toBe('lego_sets');22      expect(c.attributes.identifiers.lego_set_number).toMatch(/^\d{4,6}$/);23      expect(c.attributes.number).toBe(c.attributes.identifiers.lego_set_number);24      expect(c.attributes.brand).toBe('LEGO');25      expect(c.attributes.franchise).toBe('Star Wars');26      expect(c.attributes.originalMsrpCurrency).toBe('USD');27      expect(c.attributes.originalMsrp).toBeGreaterThan(0);28      expect(c.sourceUrl).toMatch(/lego\.com\/en-us\/product\//);29    }30    const l = lst[0]!;31    if (l.kind !== 'listing') throw new Error();32    expect(l.seller).toBe('LEGO Shop (official)');33    expect(l.currency).toBe('USD');34  });35});36