import { describe, it, expect } from 'vitest';
import { RoleFactory } from '../role-factory';

describe('RoleFactory', () => {
  it('should get admin role', () => {
    const role = RoleFactory.getRole('admin');
    expect(role.name).toBe('admin');
    expect(role.credentials.username).toBe('admin');
  });

  it('should get user role', () => {
    const role = RoleFactory.getRole('user');
    expect(role.name).toBe('user');
    expect(role.credentials.username).toBe('normaluser');
  });

  it('should throw error for unknown role', () => {
    expect(() => RoleFactory.getRole('unknown')).toThrow("Role 'unknown' not found");
  });

  it('should get all roles', () => {
    const roles = RoleFactory.getAllRoles();
    expect(roles).toHaveLength(3);
    expect(roles.map(r => r.name)).toContain('admin');
    expect(roles.map(r => r.name)).toContain('user');
    expect(roles.map(r => r.name)).toContain('test');
  });
});
