import { render, screen } from '@testing-library/react'; import { SearchResults } from './page'; const makeHit = (id: string, content: string) => ({ id, content, senderName: 'Alice', sourceGroupName: 'UP Parivar Dallas', tags: ['#important'], approvedAt: 1748390400000, }); describe('SearchResults', () => { it('shows "no results" when hits array is empty', () => { render(); expect(screen.getByText(/no results/i)).toBeInTheDocument(); }); it('renders each hit content', () => { render( , ); expect(screen.getByText('Hello world')).toBeInTheDocument(); expect(screen.getByText('Event tonight')).toBeInTheDocument(); }); it('shows the total result count', () => { render(); expect(screen.getByText(/42/)).toBeInTheDocument(); }); it('shows sender name, group name, and formatted date for each hit', () => { render(); expect(screen.getByText(/alice/i)).toBeInTheDocument(); expect(screen.getByText(/UP Parivar Dallas/i)).toBeInTheDocument(); // approvedAt: 1748390400000 — verify a date string is rendered (locale-aware) expect(screen.getByText(new Date(1748390400000).toLocaleDateString())).toBeInTheDocument(); }); it('shows tags for each hit', () => { render(); expect(screen.getByText('#important')).toBeInTheDocument(); }); });