deckhearth/test/lib/card-import-pokemon-github.test.js
varutasu 174a370fc3
Switch Pokémon catalog import to pokemon-tcg-data on GitHub. (#52)
Replace pokemontcg.io API discovery and import with raw JSON from PokemonTCG/pokemon-tcg-data; format collector numbers as number/printedTotal and drop the API key dependency for catalog sync.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-28 11:56:01 -05:00

56 lines
1.7 KiB
JavaScript

import { describe, expect, it } from 'vitest';
import {
mapGithubCardForInsert,
pokemonSetCardsUrl,
pokemonSetsUrl,
} from '../../lib/card-import/pokemon-github.js';
describe('pokemon-github URLs', () => {
it('builds default pokemon-tcg-data raw GitHub paths', () => {
expect(pokemonSetsUrl()).toBe(
'https://raw.githubusercontent.com/PokemonTCG/pokemon-tcg-data/master/sets/en.json'
);
expect(pokemonSetCardsUrl('me3')).toBe(
'https://raw.githubusercontent.com/PokemonTCG/pokemon-tcg-data/master/cards/en/me3.json'
);
});
});
describe('mapGithubCardForInsert', () => {
it('maps card fields and formats collector number with printed total', () => {
const mapped = mapGithubCardForInsert(
{
id: 'me3-18',
name: 'Seel',
supertype: 'Pokémon',
number: '18',
rarity: 'Common',
types: ['Water'],
flavorText: 'The horn on its head is sharp.',
hp: '80',
images: {
small: 'https://images.scrydex.com/pokemon/me3-18/small',
large: 'https://images.scrydex.com/pokemon/me3-18/large',
},
attacks: [{ damage: '10' }],
},
{ id: 'me3', name: 'Perfect Order', printedTotal: 88 }
);
expect(mapped).toEqual({
externalId: 'me3-18',
name: 'Seel',
setName: 'Perfect Order',
setCode: 'me3',
cardNumber: '18/88',
rarity: 'Common',
cardType: 'Pokémon',
types: ['Water'],
flavorText: 'The horn on its head is sharp.',
hp: '80',
imageSmall: 'https://images.scrydex.com/pokemon/me3-18/small',
imageLarge: 'https://images.scrydex.com/pokemon/me3-18/large',
});
});
});