import { describe, expect, it } from 'vitest'; import metaJson from './meta.json' with { type: 'json' }; import { loadFixture, runFixtureSuite } from '@rareindex/connectors/testing'; import { localMeta } from '../_lib/local-meta.js'; import createConnector from './index.js'; const connector = createConnector(localMeta(metaJson)); describe('chatterley-luxuries', () => { runFixtureSuite(connector, it, expect); it('normalises WooCommerce Store API products into USD pen listings with SKU', async () => { const fx = loadFixture('chatterley-luxuries', 'pens-p1'); const out = await connector.normalize(fx.raw); expect(out.length).toBe(1); const r = out[0]!; if (r.kind !== 'listing') throw new Error('expected listing'); expect(r.currency).toBe('USD'); expect(r.price).toBeGreaterThan(0); expect(r.attributes.categorySlug).toBe('pens'); expect(r.attributes.identifiers.sku).toBeTruthy(); expect(r.seller).toBe('Chatterley Luxuries'); expect(r.sourceUrl).toMatch(/^https:\/\/chatterleyluxuries\.com\/product\//); }); it('maps lighters through the category and title rules', async () => { const fx = loadFixture('chatterley-luxuries', 'lighters-p1'); const out = await connector.normalize(fx.raw); expect(out.length).toBe(1); expect((out[0] as { attributes: { categorySlug: string } }).attributes.categorySlug).toBe('lighters'); }); });