import { describe, expect, it } from 'vitest';
import { buildScannerCardPayload } from '../../lib/scanner-route-api.js';

describe('buildScannerCardPayload', () => {
  it('maps scanner queue fields to API body shape', () => {
    expect(
      buildScannerCardPayload({
        databaseId: 42,
        quantity: 2,
        condition: 'LP',
        isFoil: true,
        scanImageUrl: 'https://blob.example/scan.jpg',
      })
    ).toEqual({
      cardId: 42,
      quantity: 2,
      condition: 'LP',
      is_foil: true,
      scan_image_url: 'https://blob.example/scan.jpg',
    });
  });

  it('omits scan_image_url when capture was not uploaded', () => {
    expect(buildScannerCardPayload({ databaseId: 1 })).toEqual({
      cardId: 1,
      quantity: 1,
      condition: 'NM',
      is_foil: false,
    });
  });
});
