blob: 1bab46624ccce2f574ddc2a2cfb467d4c5088f18 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
import { render, screen } from '@test-utils';
import PostsList from './posts-list';
import { posts } from './posts-list.fixture';
describe('PostsList', () => {
it('renders the correct number of posts', () => {
render(<PostsList posts={posts} total={posts.length} />);
expect(screen.getAllByRole('article')).toHaveLength(posts.length);
});
it('renders the number of loaded posts', () => {
render(<PostsList posts={posts} total={posts.length} />);
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(
<PostsList posts={posts} total={posts.length} showLoadMoreBtn={true} />
);
expect(
screen.getByRole('button', { name: /Load more/i })
).toBeInTheDocument();
});
});
|