Files
gridpilot.gg/apps/website/components/actions/ActionStatusBadge.test.tsx
Marc Mintel fb1221701d
Some checks failed
Contract Testing / contract-tests (push) Failing after 6m7s
Contract Testing / contract-snapshot (push) Failing after 4m46s
add tests
2026-01-22 11:52:42 +01:00

64 lines
2.0 KiB
TypeScript

import { render, screen } from '@testing-library/react';
import { describe, it, expect } from 'vitest';
import { ActionStatusBadge } from './ActionStatusBadge';
describe('ActionStatusBadge', () => {
describe('Rendering states', () => {
it('renders PENDING status with warning variant', () => {
render(<ActionStatusBadge status="PENDING" />);
expect(screen.getByText('PENDING')).toBeDefined();
});
it('renders COMPLETED status with success variant', () => {
render(<ActionStatusBadge status="COMPLETED" />);
expect(screen.getByText('COMPLETED')).toBeDefined();
});
it('renders FAILED status with danger variant', () => {
render(<ActionStatusBadge status="FAILED" />);
expect(screen.getByText('FAILED')).toBeDefined();
});
it('renders IN_PROGRESS status with info variant', () => {
render(<ActionStatusBadge status="IN_PROGRESS" />);
expect(screen.getByText('IN PROGRESS')).toBeDefined();
});
});
describe('Visual presentation', () => {
it('formats status text by replacing underscores with spaces', () => {
render(<ActionStatusBadge status="IN_PROGRESS" />);
expect(screen.getByText('IN PROGRESS')).toBeDefined();
expect(screen.queryByText('IN_PROGRESS')).toBeNull();
});
it('renders with correct size and rounded props', () => {
const { container } = render(<ActionStatusBadge status="PENDING" />);
// The Badge component should receive size="sm" and rounded="sm"
expect(container.firstChild).toBeDefined();
});
});
describe('Edge cases', () => {
it('handles all valid status types without errors', () => {
const statuses: Array<'PENDING' | 'COMPLETED' | 'FAILED' | 'IN_PROGRESS'> = [
'PENDING',
'COMPLETED',
'FAILED',
'IN_PROGRESS',
];
statuses.forEach((status) => {
const { container } = render(<ActionStatusBadge status={status} />);
expect(container.firstChild).toBeDefined();
});
});
});
});