import { describe, expect, it } from 'vitest'; import { ConnectorMetaSchema } from '@rareindex/connectors'; import metaJson from './meta.json' with { type: 'json' }; import { listFixtures, loadFixture, runFixtureSuite } from '@rareindex/connectors/testing'; import createConnector from './index.js'; // meta.json is read directly so the suite does not depend on connectors/registry.json being regenerated. const connector = createConnector(ConnectorMetaSchema.parse(metaJson)); describe('laced', () => { runFixtureSuite(connector, it, expect); it('normalises the first fixture into catalog_item records with the expected fields', async () => { const [name] = listFixtures('laced'); const fx = loadFixture('laced', name!); const out = await connector.normalize(fx.raw); expect(out.length).toBeGreaterThan(0); const cat = out.find((r) => r.kind === 'catalog_item'); if (cat?.kind !== 'catalog_item') throw new Error('no catalog item'); expect(cat.attributes.identifiers.style_code).toMatch(/^[A-Z]{1,2}\d{4,5}-\d{3}$/); expect(cat.attributes.categorySlug).toBe('nike_jordan'); const asks = out.filter((r) => r.kind === 'listing'); expect(asks.length).toBeGreaterThan(3); for (const a of asks) if (a.kind === 'listing') { expect(a.currency).toBe('GBP'); expect(a.attributes.size).toMatch(/^UK /); } const low = out.find((r) => r.kind === 'price_observation'); if (low?.kind === 'price_observation') expect(low.price).toBeLessThanOrEqual(Math.min(...asks.map((a) => (a as { price: number }).price))); }); });