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

import {
  countUnreadTopBarNotifications,
  getTopBarCampusLabel,
  getTopBarInitials,
  getTopBarRoleLabel,
} from '@/business/top-bar/selectors';

describe('top bar selectors', () => {
  it('builds initials from display names', () => {
    expect(getTopBarInitials('Guest')).toBe('G');
    expect(getTopBarInitials('Ada Lovelace')).toBe('AL');
    expect(getTopBarInitials('  Grace  Hopper  ')).toBe('GH');
  });

  it('falls back to default campus label', () => {
    expect(getTopBarCampusLabel()).toBe('Current Campus');
  });

  it('uses shared auth role labels', () => {
    expect(getTopBarRoleLabel('support_staff')).toBe('Support Staff');
    expect(getTopBarRoleLabel('office_manager')).toBe('Office Manager');
  });

  it('counts unread notifications', () => {
    expect(countUnreadTopBarNotifications([
      { id: '1', text: 'One', time: 'Now', unread: true },
      { id: '2', text: 'Two', time: 'Earlier', unread: false },
    ])).toBe(1);
  });
});
