import { jsx as _jsx } from "react/jsx-runtime";
// @vitest-environment happy-dom
import { describe, expect, it } from 'vitest';
import { render, screen } from '@testing-library/react';
import { PostStatusBadge, PostTypeBadge, SeoScoreIndicator, seoScorePalette, paletteFor, } from '../../components/posts/badges.js';
describe('seoScorePalette', () => {
    it('returns gray for null', () => {
        expect(seoScorePalette(null)).toBe('gray');
    });
    it.each([
        [80, 'green'],
        [100, 'green'],
        [79, 'orange'],
        [60, 'orange'],
        [59, 'red'],
        [1, 'red'],
        [0, 'gray'],
    ])('score %i → %s', (input, expected) => {
        expect(seoScorePalette(input)).toBe(expected);
    });
});
describe('paletteFor', () => {
    it('falls back to gray for unknown colors', () => {
        const p = paletteFor('chartreuse');
        expect(p.bg).toContain('muted');
    });
    it('returns gray for null', () => {
        const p = paletteFor(null);
        expect(p.bg).toContain('muted');
    });
    it('returns brand tokens for "purple"', () => {
        const p = paletteFor('purple');
        expect(p.bg).toMatch(/brand/);
        expect(p.border).toMatch(/brand/);
    });
});
describe('SeoScoreIndicator', () => {
    it('renders a dash for missing score', () => {
        render(_jsx(SeoScoreIndicator, { score: null }));
        expect(screen.getByText('—')).toBeTruthy();
    });
    it('renders the numeric score when present', () => {
        render(_jsx(SeoScoreIndicator, { score: 88 }));
        expect(screen.getByText('88')).toBeTruthy();
    });
});
describe('PostStatusBadge', () => {
    it('renders the human label for each status', () => {
        render(_jsx(PostStatusBadge, { status: "PUBLISHED" }));
        expect(screen.getByText('Published')).toBeTruthy();
    });
    it('uses an aria-label so screen readers get a clean Status: foo announcement', () => {
        const { container } = render(_jsx(PostStatusBadge, { status: "SCHEDULED" }));
        expect(container.querySelector('[aria-label="Status: Scheduled"]')).toBeTruthy();
    });
});
describe('PostTypeBadge', () => {
    it('renders as a static span when no onClick is provided', () => {
        const { container } = render(_jsx(PostTypeBadge, { label: "Blog", color: "purple" }));
        expect(container.querySelector('span')?.textContent).toBe('Blog');
        expect(container.querySelector('button')).toBeNull();
    });
    it('renders as a button when onClick is provided', () => {
        render(_jsx(PostTypeBadge, { label: "Blog", color: "purple", onClick: () => { } }));
        expect(screen.getByRole('button', { name: 'Blog' })).toBeTruthy();
    });
});
//# sourceMappingURL=posts-badges.test.js.map