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.5 KB · 30 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 { listFixtures, loadFixture, runFixtureSuite } from '@rareindex/connectors/testing';5import createConnector from './index.js';67// meta.json is read directly so the suite does not depend on connectors/registry.json being regenerated.8const connector = createConnector(ConnectorMetaSchema.parse(metaJson));910describe('laced', () => {11  runFixtureSuite(connector, it, expect);1213  it('normalises the first fixture into catalog_item records with the expected fields', async () => {14    const [name] = listFixtures('laced');15    const fx = loadFixture('laced', name!);16    const out = await connector.normalize(fx.raw);17    expect(out.length).toBeGreaterThan(0);18    const cat = out.find((r) => r.kind === 'catalog_item');19    if (cat?.kind !== 'catalog_item') throw new Error('no catalog item');20    expect(cat.attributes.identifiers.style_code).toMatch(/^[A-Z]{1,2}\d{4,5}-\d{3}$/);21    expect(cat.attributes.categorySlug).toBe('nike_jordan');22    const asks = out.filter((r) => r.kind === 'listing');23    expect(asks.length).toBeGreaterThan(3);24    for (const a of asks) if (a.kind === 'listing') { expect(a.currency).toBe('GBP'); expect(a.attributes.size).toMatch(/^UK /); }25    const low = out.find((r) => r.kind === 'price_observation');26    if (low?.kind === 'price_observation') expect(low.price).toBeLessThanOrEqual(Math.min(...asks.map((a) => (a as { price: number }).price)));27  });2829});30