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.8 KB · 44 lines typescript
Raw Blame History
1import { describe, expect, it } from 'vitest';2import meta from './meta.json' with { type: 'json' };3import { localMeta } from '../../api/_lib/local-meta.js';4import { listFixtures, loadFixture, runFixtureSuite } from '@rareindex/connectors/testing';5import createConnector, { parseSetMarkdown } from './index.js';67const connector = createConnector(localMeta(meta));89const SAMPLE = `## 1999 WOTC Pokémon Base Set1011| Card # | NameGrade | VA | 1 | 9 | 10 | 10P | Total |12| --- | --- | --- | --- | --- | --- | --- | --- |13| 1/102 | [Alakazam](https://my.taggrading.com/pop-report/Pokemon/1999/WOTC%20Pok%C3%A9mon/Alakazam/1%2F102?setName=Base+Set&variation=Holo) <br>Holo | [2](x) | [2](x) | [27](x) | [5](x) | 0 | [36](x) |14| 4/102 | [Charizard](https://my.taggrading.com/x) <br>Holo | 0 | 1 | 40 | 12 | 1 | 54 |15`;1617describe('tag-pop', () => {18  runFixtureSuite(connector, it, expect);1920  it('parses the population table', () => {21    const { grades, rows } = parseSetMarkdown(SAMPLE);22    expect(grades).toEqual(['authentic', '1', '9', '10', '10P']);23    expect(rows).toHaveLength(2);24    expect(rows[0]).toMatchObject({ number: '1/102', name: 'Alakazam', variation: 'Holo', total: 36 });25    expect(rows[0]!.counts).toEqual({ authentic: 2, '1': 2, '9': 27, '10': 5 });26    expect(rows[1]!.counts['10P']).toBe(1);27  });2829  it('emits one population report per card row with grader tag', async () => {30    for (const name of listFixtures('tag-pop')) {31      const out = await connector.normalize(loadFixture('tag-pop', name).raw);32      expect(out.length).toBeGreaterThan(0);33      for (const r of out) {34        expect(r.kind).toBe('population_report');35        if (r.kind === 'population_report') {36          expect(r.grader).toBe('tag');37          expect(r.total).toBeGreaterThan(0);38          expect(r.attributes.set).toBeTruthy();39        }40      }41    }42  });43});44