import { describe, expect, it } from 'vitest'; import { readFileSync } from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { loadFixture, runFixtureSuite } from '@rareindex/connectors/testing'; import { localMeta } from '../_lib/local-meta.js'; import createConnector from './index.js'; const dir = path.dirname(fileURLToPath(import.meta.url)); const connector = createConnector(localMeta(JSON.parse(readFileSync(path.join(dir, 'meta.json'), 'utf8')))); describe('stanley-gibbons-shop', () => { runFixtureSuite(connector, it, expect); it('maps Shopify stamp products to GBP fixed-price listings with SKU identifiers', async () => { const fx = loadFixture('stanley-gibbons-shop', 'gb-products-p1'); const out = await connector.normalize(fx.raw); expect(out.length).toBe(1); const l = out[0]!; if (l.kind !== 'listing') throw new Error('listing'); expect(l).toMatchObject({ listingType: 'fixed_price', currency: 'GBP', price: 495, seller: 'Stanley Gibbons', availability: 'available', location: 'GB' }); expect(l.attributes.categorySlug).toBe('stamps'); expect(l.attributes.identifiers.sku).toBe('P267000807'); expect(l.sourceUrl).toMatch(/^https:\/\/shop\.stanleygibbons\.com\/products\//); }); it('skips excluded publications', async () => { const fx = loadFixture('stanley-gibbons-shop', 'gb-products-p1'); const raw = { ...fx.raw, payload: { ...(fx.raw.payload as object), product: { ...(fx.raw.payload as { product: Record }).product, title: 'Gibbons Stamp Monthly September 2026', product_type: 'Magazine' } } }; expect(await connector.normalize(raw)).toEqual([]); }); });