TypeScript 61.9%
HTML 37.2%
SQL 0.7%
1import { describe, expect, it } from 'vitest';2import meta from './meta.json' with { type: 'json' };3import { localMeta } from '../_lib/local-meta.js';4import { loadFixture, runFixtureSuite } from '@rareindex/connectors/testing';5import createConnector, { parseListingPage, type PagePayload } from './index.js';67const connector = createConnector(localMeta(meta));89describe('miniature-market', () => {10 runFixtureSuite(connector, it, expect);1112 it('parses Shopware product boxes, list vs. our price, ids and total pages from the saved page', () => {13 const fx = loadFixture('miniature-market', 'board-games-new-releases-html-p1');14 const p = fx.raw.payload as PagePayload;15 const parsed = parseListingPage(p.snapshot!, fx.raw.url, p.seed, p.categorySlug, 1);16 expect(parsed.boxes.length).toBeGreaterThanOrEqual(3);17 expect(parsed.totalPages).toBeGreaterThan(0);18 const b = parsed.boxes[0]!;19 expect(b.name.length).toBeGreaterThan(2);20 expect(b.url).toMatch(/^https:\/\/www\.miniaturemarket\.com\//);21 expect(b.sku).toBeTruthy();22 expect(b.productId).toMatch(/^[0-9a-f]{32}$/);23 expect(b.price).toBeGreaterThan(0);24 expect(b.buttonText).toMatch(/Add to cart|Preorder/i);25 const withList = parsed.boxes.find((x) => x.listPrice !== null);26 if (withList) expect(withList.listPrice!).toBeGreaterThanOrEqual(withList.price!);27 });2829 it('normalises to USD board-game listings carrying the retail list price as originalMsrp', async () => {30 const out = await connector.normalize(loadFixture('miniature-market', 'board-games-new-releases-html-p1').raw);31 expect(out.length).toBeGreaterThan(10);32 for (const r of out) {33 if (r.kind !== 'listing') throw new Error('expected listing');34 expect(r.attributes.categorySlug).toBe('board_games');35 expect(r.currency).toBe('USD');36 expect(r.price).toBeGreaterThan(0);37 expect(r.seller).toBe('Miniature Market');38 expect(r.attributes.identifiers.miniaturemarket_product_id ?? r.attributes.identifiers.sku).toBeTruthy();39 if (r.attributes.originalMsrp !== null) expect(r.attributes.originalMsrpCurrency).toBe('USD');40 }41 });42});43