|
| 1 | +import { render, screen } from '@testing-library/react'; |
| 2 | +import '@testing-library/jest-dom/vitest'; |
| 3 | +import { describe, it, expect } from 'vitest'; |
| 4 | +import Loading from './loading'; |
| 5 | + |
| 6 | +describe('Contributors Loading', () => { |
| 7 | + it('renders loading fallback component', () => { |
| 8 | + render(<Loading />); |
| 9 | + |
| 10 | + expect(screen.getByRole('status')).toBeInTheDocument(); |
| 11 | + }); |
| 12 | + |
| 13 | + it('renders loading messages correctly', () => { |
| 14 | + render(<Loading />); |
| 15 | + |
| 16 | + expect(screen.getByText(/loading the collective/i)).toBeInTheDocument(); |
| 17 | + |
| 18 | + expect(screen.getByText(/fetching contributor data from github/i)).toBeInTheDocument(); |
| 19 | + }); |
| 20 | + |
| 21 | + it('contains animated loader elements', () => { |
| 22 | + const { container } = render(<Loading />); |
| 23 | + |
| 24 | + expect(container.querySelector('.animate-spin')).toBeInTheDocument(); |
| 25 | + |
| 26 | + expect(container.querySelector('.animate-pulse')).toBeInTheDocument(); |
| 27 | + }); |
| 28 | + |
| 29 | + it('maintains centered flex layout and themed backdrop', () => { |
| 30 | + const { container } = render(<Loading />); |
| 31 | + |
| 32 | + const wrapper = container.firstChild as HTMLElement; |
| 33 | + |
| 34 | + expect(wrapper).toHaveClass('flex'); |
| 35 | + expect(wrapper).toHaveClass('min-h-screen'); |
| 36 | + expect(wrapper).toHaveClass('items-center'); |
| 37 | + expect(wrapper).toHaveClass('justify-center'); |
| 38 | + expect(wrapper).toHaveClass('bg-[#050505]'); |
| 39 | + }); |
| 40 | + |
| 41 | + it('renders loader container with accessibility attributes', () => { |
| 42 | + render(<Loading />); |
| 43 | + |
| 44 | + const status = screen.getByRole('status'); |
| 45 | + |
| 46 | + expect(status).toHaveAttribute('aria-live', 'polite'); |
| 47 | + }); |
| 48 | +}); |
0 commit comments