1 | import React from 'react';
|
2 | import { screen, render } from '@testing-library/react';
|
3 | import { Pagination } from '..';
|
4 | import { testForChildrenInComponent } from '../testUtils';
|
5 |
|
6 | describe('Pagination', () => {
|
7 | it('should render "nav" tag by default', () => {
|
8 | render(<Pagination data-testid="test" />);
|
9 | const node = screen.getByLabelText('pagination');
|
10 | expect(node.tagName.toLowerCase()).toMatch('nav');
|
11 | });
|
12 |
|
13 | it('should render default list tag', () => {
|
14 | render(<Pagination />);
|
15 | expect(
|
16 | screen.getByLabelText('pagination').querySelector('ul'),
|
17 | ).toBeInTheDocument();
|
18 | });
|
19 |
|
20 | it('should render custom tag', () => {
|
21 | render(<Pagination tag="main" />);
|
22 | expect(screen.getByLabelText('pagination').tagName.toLowerCase()).toBe(
|
23 | 'main',
|
24 | );
|
25 | });
|
26 |
|
27 | it('should render with "pagination" class', () => {
|
28 | render(<Pagination data-testid="pagination" />);
|
29 | expect(screen.getByTestId('pagination')).toHaveClass('pagination');
|
30 | });
|
31 |
|
32 | it('should render children', () => {
|
33 | testForChildrenInComponent(Pagination);
|
34 | });
|
35 |
|
36 | describe('should render pagination at different sizes', () => {
|
37 | it('should render with sm', () => {
|
38 | render(<Pagination size="sm" data-testid="pagination" />);
|
39 | expect(screen.getByTestId('pagination')).toHaveClass('pagination-sm');
|
40 | });
|
41 |
|
42 | it('should render lg', () => {
|
43 | render(<Pagination size="lg" data-testid="pagination" />);
|
44 | expect(screen.getByTestId('pagination')).toHaveClass('pagination-lg');
|
45 | });
|
46 | });
|
47 | });
|