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('rebag', () => { runFixtureSuite(connector, it, expect); it('normalises the first fixture into listing records with the expected fields', async () => { const [name] = listFixtures('rebag'); const fx = loadFixture('rebag', name!); const out = await connector.normalize(fx.raw); expect(out.length).toBeGreaterThan(0); const l = out.find((r) => r.kind === 'listing' && r.attributes.categorySlug === 'luxury_handbags'); if (l?.kind !== 'listing') throw new Error('no handbag listing'); expect(l.currency).toBe('USD'); expect(l.condition.conditionRaw).toBeTruthy(); expect(l.attributes.identifiers.rebag_item).toBeTruthy(); }); it('parses Rebag variant titles and retail price', async () => { const { parseVariantTitle, retailFromBody, categoryFor } = await import('./index.js'); expect(parseVariantTitle('Great | Item # 417505/4 / Blue')).toEqual({ grade: 'Great', color: 'Blue' }); expect(retailFromBody('Estimated Retail Price: $4,850
')).toBe(4850); expect(categoryFor('Top Handle Bag', 'Hermes', [])).toBe('luxury_handbags'); expect(categoryFor('Dress', 'Hermes', [])).toBe('fashion_streetwear'); }); });