import { describe, expect, it } from 'vitest'; import { ConnectorMetaSchema } from '@rareindex/connectors'; import metaJson from './meta.json' with { type: 'json' }; import { loadFixture, runFixtureSuite } from '@rareindex/connectors/testing'; import createConnector, { jpy } from './index.js'; const connector = createConnector(ConnectorMetaSchema.parse(metaJson)); describe('hobbysearch', () => { runFixtureSuite(connector, it, expect); it('emits catalog items with MSRP and JPY retailer listings', async () => { const fx = loadFixture('hobbysearch', 'gundam-mg-search-p1'); const out = await connector.normalize(fx.raw); const cats = out.filter((r) => r.kind === 'catalog_item'); const lst = out.filter((r) => r.kind === 'listing'); expect(cats.length).toBeGreaterThan(0); expect(lst.length).toBeGreaterThan(0); for (const c of cats) { if (c.kind !== 'catalog_item') continue; expect(['gundam', 'action_figures']).toContain(c.attributes.categorySlug); expect(c.attributes.identifiers.hobbysearch_id).toMatch(/^\d+$/); expect(c.sourceUrl).toMatch(/1999\.co\.jp\/eng\/\d+$/); } for (const l of lst) { if (l.kind !== 'listing') continue; expect(l.currency).toBe('JPY'); expect(l.price).toBeGreaterThan(0); expect(l.seller).toBe('HobbySearch'); } }); it('parses JPY strings', () => { expect(jpy('7,200 JPY')).toBe(7200); expect(jpy('110')).toBe(110); expect(jpy(null)).toBeNull(); }); });