/**
 * Unit tests for service error classes.
 */

import { describe, it, expect } from 'vitest';
import {
  ServiceError,
  NotFoundError,
  BadRequestError,
  UnauthorizedError,
  ForbiddenError,
} from './errors.js';

describe('ServiceError', () => {
  it('has correct status code', () => {
    const err = new ServiceError(418, "I'm a teapot");
    expect(err.statusCode).toBe(418);
    expect(err.message).toBe("I'm a teapot");
  });
});

describe('NotFoundError', () => {
  it('has 404 status', () => {
    const err = new NotFoundError();
    expect(err.statusCode).toBe(404);
  });

  it('has custom message', () => {
    const err = new NotFoundError('User not found');
    expect(err.message).toBe('User not found');
  });
});

describe('BadRequestError', () => {
  it('has 400 status', () => {
    expect(new BadRequestError().statusCode).toBe(400);
  });
});

describe('UnauthorizedError', () => {
  it('has 401 status', () => {
    expect(new UnauthorizedError().statusCode).toBe(401);
  });
});

describe('ForbiddenError', () => {
  it('has 403 status', () => {
    expect(new ForbiddenError().statusCode).toBe(403);
  });
});
