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.3 KB · 26 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, { trimEdition } from './index.js';67const connector = createConnector(localMeta(metaJson));89describe('openlibrary', () => {10  runFixtureSuite(connector, it, expect);1112  it('emits a catalog item with isbn + Open Library ids', async () => {13    const e = trimEdition({ key: '/books/OL1M', title: 'T', publishers: ['P'], publish_date: '1997', isbn_10: ['0747532699'], works: [{ key: '/works/OL2W' }], covers: [1, -1] });14    expect(e).toMatchObject({ key: '/books/OL1M', publishers: ['P'], isbn10: ['0747532699'], workKey: '/works/OL2W', covers: [1] });15    const fx = loadFixture('openlibrary', 'hp-philosophers-stone');16    const out = await connector.normalize(fx.raw);17    expect(out).toHaveLength(1);18    const c = out[0]!;19    if (c.kind !== 'catalog_item') throw new Error('expected catalog_item');20    expect(c.attributes).toMatchObject({ categorySlug: 'books', brand: 'J. K. Rowling', year: 1997 });21    expect(c.attributes.identifiers.isbn).toBeTruthy();22    expect(c.attributes.identifiers.openlibrary_id).toMatch(/^OL\d+M$/);23    expect(c.sourceUrl).toMatch(/openlibrary\.org\/books\/OL/);24  });25});26