forked from nodejs/nodejs.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpagination.test.tsx
More file actions
39 lines (35 loc) · 1.33 KB
/
pagination.test.tsx
File metadata and controls
39 lines (35 loc) · 1.33 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
import React from 'react';
import renderer from 'react-test-renderer';
import Pagination from '../../src/components/pagination';
import { createPaginationInfo } from '../__fixtures__/page';
describe('Pagination component', () => {
it('renders links to the next and previous page', () => {
const paginationInfo = createPaginationInfo();
const tree = renderer
.create(<Pagination next={paginationInfo} previous={paginationInfo} />)
.toJSON();
expect(tree).toMatchSnapshot();
});
it('renders correctly when there is no next page', () => {
const paginationInfo = createPaginationInfo();
const tree = renderer
.create(<Pagination previous={paginationInfo} />)
.toJSON();
expect(tree).toMatchSnapshot();
});
it('renders correctly when there is no previous page', () => {
const paginationInfo = createPaginationInfo();
const tree = renderer.create(<Pagination next={paginationInfo} />).toJSON();
expect(tree).toMatchSnapshot();
});
it('only renders links to pages that has a title', () => {
const paginationInfo = createPaginationInfo();
const nextPaginationInfo = { slug: 'test-slug', title: null };
const tree = renderer
.create(
<Pagination next={nextPaginationInfo} previous={paginationInfo} />
)
.toJSON();
expect(tree).toMatchSnapshot();
});
});