aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/molecules/nav/pagination.test.tsx
blob: 7662d5fb9448fe54dc5ddacc971a6fef1795ea1b (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
26
27
import { describe, expect, it } from '@jest/globals';
import { render, screen } from '../../../../tests/utils';
import { Pagination } from './pagination';

const total = 50;
const perPage = 10;

describe('Pagination', () => {
  it('renders previous and next page links', () => {
    render(<Pagination current={2} total={total} perPage={perPage} />);
    expect(
      screen.getByRole('link', { name: /Previous page/i })
    ).toBeInTheDocument();
    expect(
      screen.getByRole('link', { name: /Next page/i })
    ).toBeInTheDocument();
  });

  it('renders the page links except for the current one', () => {
    render(
      <Pagination current={2} siblings={2} total={total} perPage={perPage} />
    );
    expect(screen.getAllByRole('link', { name: /Page / })).toHaveLength(
      total / perPage - 1
    );
  });
});