TypeScript 61.9%
HTML 37.2%
SQL 0.7%
1import { describe, expect, it } from 'vitest';2import { readFileSync } from 'node:fs';3import path from 'node:path';4import { fileURLToPath } from 'node:url';5import { ConnectorMetaSchema } from '@rareindex/connectors';6import { loadFixture, runFixtureSuite } from '@rareindex/connectors/testing';7import createConnector, { parseAuctionDates, parseLotsPage, parseResultsSlugs } from './index.js';89const dir = path.dirname(fileURLToPath(import.meta.url));10const meta = ConnectorMetaSchema.parse(JSON.parse(readFileSync(path.join(dir, 'meta.json'), 'utf8')));11const connector = createConnector(meta);1213const MD = `# Monterey 20261415August 13-151617[View 1963 Ferrari 250 GT/L Berlinetta Lusso](https://www.mecum.com/lots/1175988/1963-ferrari-250-gt-l-berlinetta-lusso?aa_id=793591-0) [\\\\18\\\\19$1,650,000\\\\20\\\\21](https://www.mecum.com/lots/1175988/1963-ferrari-250-gt-l-berlinetta-lusso?aa_id=793591-0)2223Lot S1262425[Monterey 2026](https://www.mecum.com/auctions/monterey-2026/)2627[1963 Ferrari 250 GT/L Berlinetta Lusso](https://www.mecum.com/lots/1175988/1963-ferrari-250-gt-l-berlinetta-lusso?aa_id=793591-0)2829S/N 4635, The 79th of 350 Produced From 1962-643031[View 1969 Chevrolet Camaro](https://www.mecum.com/lots/1175999/1969-chevrolet-camaro?aa_id=1) [\\\\32\\\\33$50,000\\\\34\\\\35](https://www.mecum.com/lots/1175999/1969-chevrolet-camaro?aa_id=1)3637Lot S12738`;3940describe('mecum', () => {41 runFixtureSuite(connector, it, expect);4243 it('parses lots, sold badges, results slugs and auction dates', () => {44 const p = parseLotsPage(MD, 'monterey-2026', 1);45 expect(p.auctionName).toBe('Monterey 2026');46 expect(p.dateText).toBe('August 13-15');47 expect(p.lots.length).toBe(2);48 expect(p.lots[0]).toMatchObject({ lotId: '1175988', lotNumber: 'S126', sold: true, priceText: '$1,650,000', subtitle: 'S/N 4635, The 79th of 350 Produced From 1962-64' });49 expect(p.lots[1]!.sold).toBe(false);50 expect(parseResultsSlugs('<a href=\\"/auctions/monterey-2026/\\"></a><a href=\\"/auctions/houston-2026/\\">')).toEqual(['monterey-2026', 'houston-2026']);51 expect(parseAuctionDates('{\\"startDate\\":\\"2026-08-13T00:00:00+00:00\\",\\"endDate\\":\\"2026-08-15T00:00:00+00:00\\"}')).toEqual({ startDate: '2026-08-13T00:00:00+00:00', endDate: '2026-08-15T00:00:00+00:00' });52 });5354 it('normalises only sold lots, dated by the auction start, premium unknown', async () => {55 const payload = { ...parseLotsPage(MD, 'monterey-2026', 1), startDate: '2026-08-13T00:00:00+00:00', endDate: '2026-08-15T00:00:00+00:00' };56 const out = await connector.normalize({ url: 'x', externalId: 'm', kind: 'sale', engine: 'firecrawl', fetchedAt: new Date('2026-09-07T00:00:00Z'), payload });57 expect(out.length).toBe(1);58 const s = out[0]!;59 if (s.kind !== 'sale') throw new Error('sale');60 expect(s).toMatchObject({ price: 1650000, currency: 'USD', buyerPremiumIncluded: null, lotNumber: 'S126', auctionHouse: 'Mecum Auctions' });61 expect(s.saleDate.toISOString()).toBe('2026-08-13T00:00:00.000Z');62 expect(s.attributes).toMatchObject({ brand: 'Ferrari', year: 1963, categorySlug: 'automobiles' });63 });6465 it('fixture sales carry Mecum lot ids', async () => {66 const out = await connector.normalize(loadFixture('mecum', 'lots-page').raw);67 expect(out.length).toBeGreaterThan(0);68 for (const r of out) if (r.kind === 'sale') expect(r.attributes.identifiers.mecum_lot_id).toMatch(/^\d+$/);69 });70});71