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('bobs-watches', () => { runFixtureSuite(connector, it, expect); it('normalises the first fixture into listing records with the expected fields', async () => { const [name] = listFixtures('bobs-watches'); const fx = loadFixture('bobs-watches', name!); const out = await connector.normalize(fx.raw); expect(out.length).toBeGreaterThan(0); const l = out[0]; if (l?.kind !== 'listing') throw new Error('no listing'); expect(l.attributes.categorySlug).toBe('rolex'); expect(l.attributes.brand).toBe('Rolex'); expect(l.attributes.reference).toMatch(/^\d{4,6}/); expect(l.attributes.identifiers.reference).toBe(l.attributes.reference); expect(l.currency).toBe('USD'); expect(l.sourceUrl).toMatch(/bobswatches\.com\/.+\.html$/); }); });