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, { parseJpCardTitle, yen } from './index.js'; const connector = createConnector(ConnectorMetaSchema.parse(metaJson)); describe('surugaya', () => { runFixtureSuite(connector, it, expect); it('emits JPY listings with PSA grades parsed from Japanese titles', async () => { const fx = loadFixture('surugaya', 'pokemon-psa-search-p1'); const out = await connector.normalize(fx.raw); const listings = out.filter((r) => r.kind === 'listing'); expect(listings.length).toBeGreaterThan(0); const graded = out.find((r) => r.kind === 'catalog_item' && r.grade.grader === 'psa'); expect(graded).toBeTruthy(); if (graded?.kind !== 'catalog_item') throw new Error(); expect(graded.attributes.categorySlug).toBe('pokemon'); expect(graded.attributes.number).toMatch(/^\d{3}\/\d{3}$/); expect(graded.attributes.language).toBe('Japanese'); expect(graded.attributes.identifiers.surugaya_id).toBeTruthy(); for (const l of listings) { if (l.kind !== 'listing') continue; expect(l.currency).toBe('JPY'); expect(l.sourceUrl).toMatch(/suruga-ya\.jp\/product\//); } }); it('helpers', () => { expect(yen('中古:¥12,800')).toBe(12800); expect(yen('品切れ')).toBeNull(); expect(parseJpCardTitle('114/083[SAR]:【PSA/GEM MT 10】(キラ)メガゲッコウガex')).toEqual({ number: '114/083', rarity: 'SAR', name: 'メガゲッコウガex', grader: 'psa', grade: '10' }); expect(parseJpCardTitle('096/071[SAR]:【PSA/MINT 9】(キラ)ナンジャモ').grade).toBe('9'); expect(parseJpCardTitle('ポケモンカードゲーム デッキシールド').grader).toBeNull(); }); });