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, { parsePastPage } 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 = `- [\\\\14\\\\15Featured\\\\16\\\\17 - Bid to $138,000](https://carsandbids.com/auctions/rJv85YAw/2023-porsche-panamera-turbo-s "2023 Porsche Panamera Turbo S")1819[2023 Porsche Panamera Turbo S](https://carsandbids.com/auctions/rJv85YAw/2023-porsche-panamera-turbo-s "2023 Porsche Panamera Turbo S") Watch2021620-hp Twin-Turbo V8, AWD2223Ended 9/4/262425- [\\\\26\\\\27 - Sold for $7,400](https://carsandbids.com/auctions/3BOndoY4/1977-mercury-marquis-colony-park-brougham-wagon "1977 Mercury Marquis Colony Park Brougham Wagon")2829[1977 Mercury Marquis Colony Park Brougham Wagon](https://carsandbids.com/auctions/3BOndoY4/1977-mercury-marquis-colony-park-brougham-wagon "1977 Mercury Marquis Colony Park Brougham Wagon") Watch3031460ci V8, A/C, Third-Row Seating3233Ended 9/4/2634`;3536describe('cars-and-bids', () => {37 runFixtureSuite(connector, it, expect);3839 it('parses the past-auctions markdown', () => {40 const p = parsePastPage(SAMPLE, 1);41 expect(p.items.length).toBe(2);42 expect(p.items[0]).toMatchObject({ id: 'rJv85YAw', statusText: 'Bid to $138,000', ended: '9/4/26' });43 expect(p.items[1]).toMatchObject({ id: '3BOndoY4', title: '1977 Mercury Marquis Colony Park Brougham Wagon', statusText: 'Sold for $7,400', ended: '9/4/26', subtitle: '460ci V8, A/C, Third-Row Seating' });44 });4546 it('normalises only sold rows, hammer price without buyer fee', async () => {47 const out = await connector.normalize({ url: 'https://carsandbids.com/past-auctions/', externalId: 'past:1', kind: 'sale', engine: 'firecrawl', fetchedAt: new Date('2026-09-07T00:00:00Z'), payload: parsePastPage(SAMPLE, 1) });48 expect(out.length).toBe(1);49 const s = out[0]!;50 if (s.kind !== 'sale') throw new Error('sale expected');51 expect(s).toMatchObject({ price: 7400, currency: 'USD', buyerPremiumIncluded: false, auctionHouse: 'Cars & Bids', externalId: '3BOndoY4' });52 expect(s.saleDate.toISOString()).toBe('2026-09-04T00:00:00.000Z');53 expect(s.attributes).toMatchObject({ categorySlug: 'automobiles', brand: 'Mercury', year: 1977 });54 });5556 it('fixture sales carry real end dates and ids', async () => {57 const fx = loadFixture('cars-and-bids', 'past-page');58 const out = await connector.normalize(fx.raw);59 for (const r of out) {60 if (r.kind !== 'sale') continue;61 expect(r.attributes.identifiers.carsandbids_id).toMatch(/^[A-Za-z0-9]+$/);62 expect(r.saleDate.getUTCFullYear()).toBeGreaterThanOrEqual(2020);63 }64 });65});66