import { describe, expect, it } from 'vitest';
import { GatewayError } from './client';

describe('GatewayError', () => {
  it('carries a stable code and is a real Error', () => {
    const e = new GatewayError('no_hint_available');
    expect(e).toBeInstanceOf(Error);
    expect(e.name).toBe('GatewayError');
    expect(e.code).toBe('no_hint_available');
    expect(e.message).toBe('no_hint_available'); // message defaults to the code
  });

  it('keeps a custom message while the code stays the i18n lookup key', () => {
    const e = new GatewayError('not_your_turn', 'It is not your turn');
    expect(e.code).toBe('not_your_turn');
    expect(e.message).toBe('It is not your turn');
  });
});
