import { render, screen } from '../../../../tests/utils'; import { PostsList } from './posts-list'; import { posts, searchPage } from './posts-list.fixture'; describe('PostsList', () => { it('renders the correct number of posts', () => { render( ); expect(screen.getAllByRole('article')).toHaveLength(posts.length); }); it('renders the number of loaded posts', () => { render( ); const info = `${posts.length} loaded articles out of a total of ${posts.length}`; expect(screen.getByText(info)).toBeInTheDocument(); }); it('renders a load more button', () => { render( ); expect( screen.getByRole('button', { name: /Load more/i }) ).toBeInTheDocument(); }); it('renders a search form if no results', () => { render( ); expect(screen.getByRole('searchbox')).toBeInTheDocument(); }); });