import { describe, it, expect } from 'vitest';
import { LOCAL_ID_PREFIX, isLocalGameId, newLocalGameId, randomSeed } from './id';

describe('local game id helpers', () => {
  it('recognises local ids by prefix', () => {
    expect(isLocalGameId(LOCAL_ID_PREFIX + 'x')).toBe(true);
    expect(isLocalGameId('deadbeef')).toBe(false);
  });

  it('mints unique local ids', () => {
    const a = newLocalGameId();
    const b = newLocalGameId();
    expect(isLocalGameId(a)).toBe(true);
    expect(a).not.toBe(b);
  });

  it('produces a bigint seed in the 32-bit range', () => {
    for (let i = 0; i < 50; i++) {
      const s = randomSeed();
      expect(typeof s).toBe('bigint');
      expect(s >= 0n && s <= 0xffffffffn).toBe(true);
    }
  });
});
