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, { parseSoldPage } 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 SAMPLE = `Showing 26,189 lots1415- [\\\\16\\\\17Sold](https://collectingcars.com/for-sale/2013-land-rover-discovery-4-5-0l-v8-2)1819[Sold\\\\20\\\\21**2013 Land Rover Discovery 4 5.0 V8** \\\\22\\\\23Sold\\\\24\\\\25£17,000\\\\26\\\\2706/09/2026\\\\28\\\\29Gatwick](https://collectingcars.com/for-sale/2013-land-rover-discovery-4-5-0l-v8-2)3031- [\\\\32\\\\33Sold](https://collectingcars.com/for-sale/1997-porsche-911-993-targa-17)3435[Sold\\\\36\\\\37**1997 Porsche 911 (993) Targa - Manual** \\\\38\\\\3906/09/2026\\\\40Sign in to view sold price\\\\41\\\\42Bristol](https://collectingcars.com/for-sale/1997-porsche-911-993-targa-17)43`;4445describe('collecting-cars', () => {46 runFixtureSuite(connector, it, expect);4748 it('keeps only lots whose price is public (never the sign-in-gated ones)', () => {49 const p = parseSoldPage(SAMPLE, 1);50 expect(p.total).toBe(26189);51 expect(p.items.length).toBe(1);52 expect(p.items[0]).toMatchObject({ slug: '2013-land-rover-discovery-4-5-0l-v8-2', priceText: '£17,000', dateText: '06/09/2026', country: 'United Kingdom', town: 'Gatwick' });53 });5455 it('normalises with GBP, dd/mm/yyyy date and hammer semantics', async () => {56 const out = await connector.normalize({ url: 'https://collectingcars.com/sold', externalId: 'sold:1', kind: 'sale', engine: 'firecrawl', fetchedAt: new Date('2026-09-07T00:00:00Z'), payload: parseSoldPage(SAMPLE, 1) });57 expect(out.length).toBe(1);58 const s = out[0]!;59 if (s.kind !== 'sale') throw new Error('sale expected');60 expect(s).toMatchObject({ price: 17000, currency: 'GBP', buyerPremiumIncluded: false, auctionHouse: 'Collecting Cars', location: 'Gatwick, United Kingdom' });61 expect(s.saleDate.toISOString()).toBe('2026-09-06T00:00:00.000Z');62 expect(s.attributes).toMatchObject({ brand: 'Land Rover', year: 2013, categorySlug: 'automobiles' });63 });6465 it('fixture records have currencies and dates', async () => {66 const out = await connector.normalize(loadFixture('collecting-cars', 'sold-page').raw);67 for (const r of out) if (r.kind === 'sale') expect(['GBP', 'EUR', 'AUD', 'USD', 'AED', 'CAD', 'NZD', 'CHF']).toContain(r.currency);68 });69});70