import { jsx as _jsx } from "react/jsx-runtime";
// @vitest-environment happy-dom
import { afterEach, describe, expect, it } from 'vitest';
import { cleanup, render } from '@testing-library/react';
import { AuthorAvatar, authorAvatar } from '../../components/ui/AuthorAvatar.js';
afterEach(cleanup);
describe('authorAvatar', () => {
    it('derives two initials from first + last name', () => {
        expect(authorAvatar('Maria Kowalski').initials).toBe('MK');
        expect(authorAvatar('Sarah M. Lee').initials).toBe('SL');
    });
    it('falls back to the first two characters for single-word names', () => {
        expect(authorAvatar('Admin').initials).toBe('AD');
    });
    it('handles null/empty names without throwing', () => {
        expect(authorAvatar(null).initials).toBe('US');
        expect(authorAvatar('  ').initials).toBe('US');
    });
    it('assigns a stable color per name', () => {
        const first = authorAvatar('Maria Kowalski').color;
        const second = authorAvatar('Maria Kowalski').color;
        expect(first).toBe(second);
        expect(first).toMatch(/^#[0-9A-F]{6}$/i);
    });
});
describe('AuthorAvatar', () => {
    it('renders the initials in a colored circle, hidden from AT', () => {
        const { container } = render(_jsx(AuthorAvatar, { name: "Maria Kowalski", size: 28 }));
        const el = container.firstElementChild;
        expect(el.textContent).toBe('MK');
        expect(el.getAttribute('aria-hidden')).toBe('true');
        expect(el.style.background).not.toBe('');
        expect(el.style.width).toBe('28px');
    });
});
//# sourceMappingURL=author-avatar.test.js.map