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('crown-caliber', () => { runFixtureSuite(connector, it, expect); it('normalises the first fixture into listing records with the expected fields', async () => { const [name] = listFixtures('crown-caliber'); const fx = loadFixture('crown-caliber', 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.reference).toBeTruthy(); expect(l.currency).toBe('USD'); expect(l.sourceUrl).toMatch(/europeanwatch\.com\/watch\//); }); it('splits names into reference + model and reads circa years', async () => { const { splitName } = await import('./index.js'); expect(splitName('Rolex 16710 GMT-Master II Coke Bezel SS Black Dial Circa. 2000', 'Rolex')).toEqual({ reference: '16710', model: 'GMT-Master II Coke Bezel' }); expect(splitName('Patek Philippe 5711/1A-010 Nautilus SS Blue Dial', 'Patek Philippe')).toMatchObject({ reference: '5711/1A-010' }); }); });