import { describe, it, expect } from 'vitest';
import type { Character } from '@/lib/schemas';
import { unplacedPcs } from './tokens';

const pc = (id: string): Character => ({ id, name: id } as unknown as Character);

describe('unplacedPcs', () => {
  it('returns only PCs without a linked token', () => {
    const pcs = [pc('a'), pc('b'), pc('c')];
    const tokens = [{ characterId: 'b' }, { characterId: undefined }];
    expect(unplacedPcs(pcs, tokens).map((c) => c.id)).toEqual(['a', 'c']);
  });

  it('returns all when none placed, none when all placed', () => {
    const pcs = [pc('a'), pc('b')];
    expect(unplacedPcs(pcs, []).map((c) => c.id)).toEqual(['a', 'b']);
    expect(unplacedPcs(pcs, [{ characterId: 'a' }, { characterId: 'b' }])).toEqual([]);
  });
});
