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%
2.0 KB · 36 lines typescript
Raw Blame History
1import { describe, expect, it } from 'vitest';2import { ConnectorMetaSchema } from '@rareindex/connectors';3import metaJson from './meta.json' with { type: 'json' };4import { listFixtures, loadFixture, runFixtureSuite } from '@rareindex/connectors/testing';5import createConnector from './index.js';67// meta.json is read directly so the suite does not depend on connectors/registry.json being regenerated.8const connector = createConnector(ConnectorMetaSchema.parse(metaJson));910describe('fashionphile', () => {11  runFixtureSuite(connector, it, expect);1213  it('normalises the first fixture into listing records with the expected fields', async () => {14    const [name] = listFixtures('fashionphile');15    const fx = loadFixture('fashionphile', name!);16    const out = await connector.normalize(fx.raw);17    expect(out.length).toBeGreaterThan(0);18    const l = out.find((r) => r.kind === 'listing');19    if (l?.kind !== 'listing') throw new Error('no listing');20    expect(l.currency).toBe('USD');21    expect(l.price).toBeGreaterThan(0);22    expect(l.seller).toBe('FASHIONPHILE');23    expect(['luxury_handbags', 'fashion_streetwear', 'jewelry', 'rolex', 'other_watches']).toContain(l.attributes.categorySlug);24    expect(l.attributes.brand).toBeTruthy();25    expect(l.attributes.identifiers.fashionphile_sku).toBeTruthy();26    expect(new Set(out.map((r) => (r as { availability?: string }).availability))).toBeTruthy();27  });28  it('maps sold-out published products to availability=sold and classifies shoes as fashion', async () => {29    const { categoryFor } = await import('./index.js');30    expect(categoryFor('Shoes', 'Hermes', 'Calfskin Womens Mage Sandals 39 Black')).toBe('fashion_streetwear');31    expect(categoryFor('', 'Hermes', 'Calfskin Womens Mage Sandals 39 Black')).toBe('fashion_streetwear');32    expect(categoryFor('Bags', 'Hermes', 'Togo Birkin 30 Gold')).toBe('luxury_handbags');33    expect(categoryFor('Watches', 'Rolex', 'Stainless Steel Datejust 36 Watch')).toBe('rolex');34  });35});36