TypeScript 61.9%
HTML 37.2%
SQL 0.7%
1import { describe, expect, it } from 'vitest';2import { ConnectorMetaSchema } from '@rareindex/connectors';3import { loadFixture, runFixtureSuite } from '@rareindex/connectors/testing';4import metaJson from './meta.json' with { type: 'json' };5import createConnector, { parseArchive, parseResultsPdf, wineFacts } from './index.js';67const connector = createConnector(ConnectorMetaSchema.parse(metaJson));89describe('hdh-wine', () => {10 runFixtureSuite(connector, it, expect);1112 it('maps PDF rows to USD hammer sales, grouping multi-row lots', async () => {13 const fx = loadFixture('hdh-wine', 'results-pdf');14 const out = await connector.normalize(fx.raw);15 expect(out.length).toBeGreaterThan(0);16 for (const r of out) {17 if (r.kind !== 'sale') throw new Error('expected sale');18 expect(r.currency).toBe('USD');19 expect(r.buyerPremiumIncluded).toBe(false);20 expect(['wine', 'whisky', 'cognac']).toContain(r.attributes.categorySlug);21 expect(r.attributes.identifiers.hdh_lot).toMatch(/:\d+/);22 expect(r.auctionHouse).toBe('Hart Davis Hart Wine Co.');23 }24 });2526 it('parses the PDF table, header date and archive links', () => {27 const md = `## Aggregate: 3,892,330 August 27-28, 2026\n\n| Lot | Qty | Description | Estimate | Hammer | Aggregate |\n| --- | --- | --- | --- | --- | --- |\n| 1 | 6 | 1982 Château Ducru-Beaucaillou | 1,600 - 2,400 | 2,200 | 2,629.00 |\n| 5 | 1 | 2009 Château Cos d'Estournel | 500 - 750 | 900 | 1,075.50 |\n| 5 | 1 | 2010 Château Léoville Poyferré | | | |\n| 8 | 1 | 2009 Château d'Yquem (375ml) | 280 - 420 | 500 | 597.50 |\n`;28 const p = parseResultsPdf(md);29 expect(p.saleDate).toBe('2026-08-27T00:00:00.000Z');30 expect(p.rows).toHaveLength(4);31 expect(p.rows[0]).toMatchObject({ lot: '1', qty: 6, hammer: 2200, aggregate: 2629 });32 expect(p.rows[2]!.hammer).toBeNull();33 expect(wineFacts('2009 Château d\'Yquem (375ml)')).toMatchObject({ vintage: 2009, size: '375ml', name: "Château d'Yquem", categorySlug: 'wine' });34 expect(wineFacts('2017 La Tâche, Domaine de la Romanée-Conti')).toMatchObject({ producer: 'Domaine de la Romanée-Conti' });35 const arch = parseArchive('**An Auction of Finest & Rarest Wines**\n\nJune 25 & 26, 2026\n\n**100% SOLD**\n\n[View auction results](https://hdhauctions.com/wp-content/uploads/2026/07/2606_AuctionResults_PDF.pdf)');36 expect(arch).toHaveLength(1);37 expect(arch[0]).toMatchObject({ pdfUrl: 'https://hdhauctions.com/wp-content/uploads/2026/07/2606_AuctionResults_PDF.pdf', title: 'An Auction of Finest & Rarest Wines', dateText: 'June 25 & 26, 2026' });38 });3940 it('groups a two-row lot into one bundle sale', async () => {41 const out = await connector.normalize({ url: 'https://hdhauctions.com/wp-content/uploads/2026/08/2608_AuctionResults.pdf', externalId: null, kind: 'sale', engine: 'firecrawl', fetchedAt: new Date(), payload: { kind: 'results_pdf', url: 'https://hdhauctions.com/wp-content/uploads/2026/08/2608_AuctionResults.pdf', auctionName: 'x', saleDate: '2026-08-27T00:00:00.000Z', rows: [{ lot: '5', qty: 1, description: "2009 Château Cos d'Estournel", estimate: '500 - 750', hammer: 900, aggregate: 1075.5 }, { lot: '5', qty: 1, description: '2010 Château Montrose', estimate: null, hammer: null, aggregate: null }] } });42 expect(out).toHaveLength(1);43 const s = out[0]!;44 if (s.kind !== 'sale') throw new Error('sale');45 expect(s.isBundle).toBe(true);46 expect(s.price).toBe(900);47 expect(s.lotNumber).toBe('5');48 });49});50