import {
  describe,
  expect,
  it
} from 'vitest';

import { localizeSystemRoleDisplayName, resolveSystemRoleDisplayI18nKey } from './role-display.rules';

describe('role-display.rules', () => {
  describe('resolveSystemRoleDisplayI18nKey', () => {
    it('maps built-in role display names to i18n keys', () => {
      expect(resolveSystemRoleDisplayI18nKey('Member')).toBe('shared.leaveServer.roles.member');
      expect(resolveSystemRoleDisplayI18nKey('Owner')).toBe('shared.leaveServer.roles.owner');
      expect(resolveSystemRoleDisplayI18nKey('@everyone')).toBe('shared.accessControl.roles.everyone');
      expect(resolveSystemRoleDisplayI18nKey('Moderator')).toBe('shared.leaveServer.roles.moderator');
      expect(resolveSystemRoleDisplayI18nKey('Admin')).toBe('shared.leaveServer.roles.admin');
    });

    it('returns null for custom role names', () => {
      expect(resolveSystemRoleDisplayI18nKey('Custom Role')).toBeNull();
    });
  });

  describe('localizeSystemRoleDisplayName', () => {
    it('translates known system role names', () => {
      const translate = (key: string) => `translated:${key}`;

      expect(localizeSystemRoleDisplayName('Admin', translate)).toBe('translated:shared.leaveServer.roles.admin');
    });

    it('returns custom role names unchanged', () => {
      const translate = (key: string) => `translated:${key}`;

      expect(localizeSystemRoleDisplayName('Event Host', translate)).toBe('Event Host');
    });
  });
});
