import { describe, expect, it } from 'vitest';
import { ConnectorMetaSchema } from '@rareindex/connectors';
import { listFixtures, loadFixture, runFixtureSuite } from '@rareindex/connectors/testing';
import metaJson from './meta.json' with { type: 'json' };
import createConnector from './index.js';
import { parseGoauctionCalendar } from '../_g8-auctions-eu-apac-lib/goauction-platform.js';
const meta = ConnectorMetaSchema.parse(metaJson);
const connector = createConnector(meta);
const CAL = `
`;
describe('chiswick-auctions', () => {
runFixtureSuite(connector, it, expect);
it('fixtures: GBP results from the goauction grid', async () => {
let sales = 0;
for (const name of listFixtures('chiswick-auctions')) {
for (const r of await connector.normalize(loadFixture('chiswick-auctions', name).raw)) {
if (!('attributes' in r)) continue;
expect(r.attributes.identifiers.chiswick_lot).toMatch(/^\d+\/\S+$/);
if (r.kind === 'sale') {
sales++;
expect(r.currency).toBe('GBP');
expect(r.auctionHouse).toBe('Chiswick Auctions');
expect(r.buyerPremiumIncluded).toBeNull();
}
}
}
expect(sales).toBeGreaterThan(10);
});
it('parses the calendar with absolute (non-www) links and H6 titles', () => {
const sales = parseGoauctionCalendar(CAL, { base: 'https://www.chiswickauctions.co.uk', currency: 'GBP', listStyle: 'details' });
expect(sales).toHaveLength(1);
expect(sales[0]).toMatchObject({ id: '1385', title: 'Affordable Jewellery, Watches, Silver & Coins - Timed Online', date: '2026-09-04T00:00:00.000Z', url: 'https://chiswickauctions.co.uk/auction/details/4sept26-affordable-jewellery-watches-silver--coins---timed-online?au=1385' });
});
});