import { describe, expect, it } from 'vitest';

import { buildCatalogSyncQueue } from '../../lib/card-import/sync-catalog.js';

describe('buildCatalogSyncQueue', () => {
  it('merges MTG and Pokémon missing sets by release date, newest first', () => {
    const queue = buildCatalogSyncQueue(
      [
        { code: 'fin', name: 'Final Fantasy', releasedAt: '2026-05-01' },
        { code: 'dsk', name: 'Duskmourn', releasedAt: '2024-09-27' },
      ],
      [
        { id: 'sv10', name: 'Perfect Order', releasedAt: '2026-03-27' },
        { id: 'sv9', name: 'Journey Together', releasedAt: '2025-03-28' },
      ],
      3
    );

    expect(queue).toEqual([
      {
        game: 'mtg',
        setCode: 'fin',
        name: 'Final Fantasy',
        releasedAt: '2026-05-01',
      },
      {
        game: 'pokemon',
        setCode: 'sv10',
        name: 'Perfect Order',
        releasedAt: '2026-03-27',
      },
      {
        game: 'pokemon',
        setCode: 'sv9',
        name: 'Journey Together',
        releasedAt: '2025-03-28',
      },
    ]);
  });
});
