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%
1.4 KB · 33 lines typescript
Raw Blame History
1import { describe, expect, it } from 'vitest';2import metaJson from './meta.json' with { type: 'json' };3import { loadFixture, runFixtureSuite } from '@rareindex/connectors/testing';4import { localMeta } from '../_lib/local-meta.js';5import createConnector from './index.js';67const connector = createConnector(localMeta(metaJson));89describe('chatterley-luxuries', () => {10  runFixtureSuite(connector, it, expect);1112  it('normalises WooCommerce Store API products into USD pen listings with SKU', async () => {13    const fx = loadFixture('chatterley-luxuries', 'pens-p1');14    const out = await connector.normalize(fx.raw);15    expect(out.length).toBe(1);16    const r = out[0]!;17    if (r.kind !== 'listing') throw new Error('expected listing');18    expect(r.currency).toBe('USD');19    expect(r.price).toBeGreaterThan(0);20    expect(r.attributes.categorySlug).toBe('pens');21    expect(r.attributes.identifiers.sku).toBeTruthy();22    expect(r.seller).toBe('Chatterley Luxuries');23    expect(r.sourceUrl).toMatch(/^https:\/\/chatterleyluxuries\.com\/product\//);24  });2526  it('maps lighters through the category and title rules', async () => {27    const fx = loadFixture('chatterley-luxuries', 'lighters-p1');28    const out = await connector.normalize(fx.raw);29    expect(out.length).toBe(1);30    expect((out[0] as { attributes: { categorySlug: string } }).attributes.categorySlug).toBe('lighters');31  });32});33