Files
fast-next-template/frontend/tests/components/projects/StatusBadge.test.tsx
Felipe Cardoso a4c91cb8c3 refactor(frontend): clean up code by consolidating multi-line JSX into single lines where feasible
- Refactored JSX elements to improve readability by collapsing multi-line props and attributes into single lines if their length permits.
- Improved consistency in component imports by grouping and consolidating them.
- No functional changes, purely restructuring for clarity and maintainability.
2026-01-01 11:46:57 +01:00

59 lines
2.1 KiB
TypeScript

import { render, screen } from '@testing-library/react';
import { ProjectStatusBadge, AutonomyBadge } from '@/components/projects/StatusBadge';
describe('ProjectStatusBadge', () => {
it('renders active status correctly', () => {
render(<ProjectStatusBadge status="active" />);
expect(screen.getByText('Active')).toBeInTheDocument();
});
it('renders completed status correctly', () => {
render(<ProjectStatusBadge status="completed" />);
expect(screen.getByText('Completed')).toBeInTheDocument();
});
it('renders paused status correctly', () => {
render(<ProjectStatusBadge status="paused" />);
expect(screen.getByText('Paused')).toBeInTheDocument();
});
it('renders archived status correctly', () => {
render(<ProjectStatusBadge status="archived" />);
expect(screen.getByText('Archived')).toBeInTheDocument();
});
it('applies custom className', () => {
const { container } = render(<ProjectStatusBadge status="active" className="custom-class" />);
expect(container.firstChild).toHaveClass('custom-class');
});
});
describe('AutonomyBadge', () => {
it('renders full_control level correctly', () => {
render(<AutonomyBadge level="full_control" />);
expect(screen.getByText('Full Control')).toBeInTheDocument();
});
it('renders milestone level correctly', () => {
render(<AutonomyBadge level="milestone" />);
expect(screen.getByText('Milestone')).toBeInTheDocument();
});
it('renders autonomous level correctly', () => {
render(<AutonomyBadge level="autonomous" />);
expect(screen.getByText('Autonomous')).toBeInTheDocument();
});
it('has title attribute with description', () => {
render(<AutonomyBadge level="milestone" />);
// The Badge component is the closest ancestor with the title
const badge = screen.getByText('Milestone').closest('[title]');
expect(badge).toHaveAttribute('title', 'Approve at sprint boundaries');
});
it('applies custom className', () => {
const { container } = render(<AutonomyBadge level="milestone" className="custom-class" />);
expect(container.firstChild).toHaveClass('custom-class');
});
});