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('fashionphile', () => { runFixtureSuite(connector, it, expect); it('normalises the first fixture into listing records with the expected fields', async () => { const [name] = listFixtures('fashionphile'); const fx = loadFixture('fashionphile', name!); const out = await connector.normalize(fx.raw); expect(out.length).toBeGreaterThan(0); const l = out.find((r) => r.kind === 'listing'); if (l?.kind !== 'listing') throw new Error('no listing'); expect(l.currency).toBe('USD'); expect(l.price).toBeGreaterThan(0); expect(l.seller).toBe('FASHIONPHILE'); expect(['luxury_handbags', 'fashion_streetwear', 'jewelry', 'rolex', 'other_watches']).toContain(l.attributes.categorySlug); expect(l.attributes.brand).toBeTruthy(); expect(l.attributes.identifiers.fashionphile_sku).toBeTruthy(); expect(new Set(out.map((r) => (r as { availability?: string }).availability))).toBeTruthy(); }); it('maps sold-out published products to availability=sold and classifies shoes as fashion', async () => { const { categoryFor } = await import('./index.js'); expect(categoryFor('Shoes', 'Hermes', 'Calfskin Womens Mage Sandals 39 Black')).toBe('fashion_streetwear'); expect(categoryFor('', 'Hermes', 'Calfskin Womens Mage Sandals 39 Black')).toBe('fashion_streetwear'); expect(categoryFor('Bags', 'Hermes', 'Togo Birkin 30 Gold')).toBe('luxury_handbags'); expect(categoryFor('Watches', 'Rolex', 'Stainless Steel Datejust 36 Watch')).toBe('rolex'); }); });