|
| 1 | +import { render, screen, within } from '@testing-library/react'; |
| 2 | +import { describe, expect, it } from 'vitest'; |
| 3 | +import { BoardPreview } from './BoardPreview'; |
| 4 | + |
| 5 | +describe('BoardPreview', () => { |
| 6 | + it('renders the three planned columns', () => { |
| 7 | + render(<BoardPreview />); |
| 8 | + for (const title of ['Backlog', 'In progress', 'Shipped']) { |
| 9 | + expect( |
| 10 | + screen.getByRole('heading', { level: 3, name: title }), |
| 11 | + ).toBeInTheDocument(); |
| 12 | + } |
| 13 | + }); |
| 14 | + |
| 15 | + it('pairs each column with its own status pill', () => { |
| 16 | + render(<BoardPreview />); |
| 17 | + const badges = screen.getAllByTestId('status-badge'); |
| 18 | + expect(badges.map((badge) => badge.textContent)).toEqual([ |
| 19 | + 'To do', |
| 20 | + 'In progress', |
| 21 | + 'Done', |
| 22 | + ]); |
| 23 | + }); |
| 24 | + |
| 25 | + it('shows the tasks under the column they belong to', () => { |
| 26 | + render(<BoardPreview />); |
| 27 | + const shipped = screen |
| 28 | + .getByRole('heading', { name: 'Shipped' }) |
| 29 | + .closest('section') as HTMLElement; |
| 30 | + const tasks = within(shipped).getAllByRole('listitem'); |
| 31 | + expect(tasks.map((task) => task.textContent)).toEqual([ |
| 32 | + 'Health and readiness endpoints', |
| 33 | + 'CI, Docker builds, smoke checks', |
| 34 | + ]); |
| 35 | + }); |
| 36 | +}); |
0 commit comments