SPB Git forge

spb/rareindex

Public
54commits 1branches 0releases
7.1 MBsize
maindefault branch
10 days agolast push
TypeScript 61.9% HTML 37.2% SQL 0.7%
3.5 KB · 93 lines typescript
Raw Blame History
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, { parseLotsPage, parseResults } 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 RESULTS = `![](https://cdn.rmsothebys.com/a.webp)1415‹›1617The Monterey Auction181913 - 15 August 20262021[View Results](https://rmsothebys.com/auctions/mo26/lots/)2223![](https://cdn.rmsothebys.com/b.webp)2425‹›2627Sealed July2829Bidding Closes 16 July 20263031[View Results](https://rmsothebys.com/auctions/s0726/lots/r0001-x/)32`;3334const LOTS = `[![F-Racer Junior](https://cdn.rmsothebys.com/c.webp)](https://rmsothebys.com/auctions/mo25/lots/n0001-fracer-junior/)3536![](https://rmsothebys.com/media/General/Flags/us.png)[**Monterey 2025** \\\\37F-Racer Junior\\\\38\\\\39Lot 101 \\| $24,000 USD\\\\40\\\\41Sold\\\\42\\\\43n0001 - \\\\44\\\\45Current bid: \\\\46\\\\47Final Bid: \\|  Lot Sold Lot Closed\\\\48\\\\49Bid](https://rmsothebys.com/auctions/mo25/lots/n0001-fracer-junior/)5051[![1997 Porsche 911 Cup 3.8 RSR](https://cdn.rmsothebys.com/d.webp)](https://rmsothebys.com/auctions/mo25/lots/r0085-1997-porsche-911-cup-38-rsr/)5253![](https://rmsothebys.com/media/General/Flags/us.png)[**Monterey 2025** \\\\541997 Porsche 911 Cup 3.8 RSR\\\\55\\\\56Lot 126 \\| Estimate Available Upon Request\\\\57\\\\58Not Sold\\\\59\\\\60r0085 - \\\\61\\\\62Bid](https://rmsothebys.com/auctions/mo25/lots/r0085-1997-porsche-911-cup-38-rsr/)63`;6465describe('rm-sothebys', () => {66  runFixtureSuite(connector, it, expect);6768  it('parses the results list and the lot grid', () => {69    const auctions = parseResults(RESULTS);70    expect(auctions[0]).toEqual({ code: 'mo26', name: 'The Monterey Auction', dateText: '13 - 15 August 2026' });71    expect(auctions[1]).toMatchObject({ code: 's0726', name: 'Sealed July', dateText: '16 July 2026' });72    const lots = parseLotsPage(LOTS, { code: 'mo25', name: 'Monterey 2025', dateText: '15 - 16 August 2025' }).lots;73    expect(lots.length).toBe(2);74    expect(lots[0]).toMatchObject({ slug: 'n0001-fracer-junior', title: 'F-Racer Junior', lotNumber: '101', priceText: '$24,000 USD', status: 'Sold' });75    expect(lots[1]).toMatchObject({ lotNumber: '126', priceText: null, status: 'Not Sold' });76  });7778  it('normalises sold lots with premium included and the auction start date', async () => {79    const out = await connector.normalize({ url: 'x', externalId: 'r', kind: 'sale', engine: 'firecrawl', fetchedAt: new Date('2026-09-07T00:00:00Z'), payload: parseLotsPage(LOTS, { code: 'mo25', name: 'Monterey 2025', dateText: '15 - 16 August 2025' }) });80    expect(out.length).toBe(1);81    const s = out[0]!;82    if (s.kind !== 'sale') throw new Error('sale');83    expect(s).toMatchObject({ price: 24000, currency: 'USD', buyerPremiumIncluded: true, lotNumber: '101', auctionHouse: "RM Sotheby's" });84    expect(s.saleDate.toISOString()).toBe('2025-08-15T00:00:00.000Z');85  });8687  it('fixture sales have currencies and lot numbers', async () => {88    const out = await connector.normalize(loadFixture('rm-sothebys', 'lots-page').raw);89    expect(out.length).toBeGreaterThan(0);90    for (const r of out) if (r.kind === 'sale') expect(r.lotNumber).toBeTruthy();91  });92});93