2018-09-16 13:18:02 +03:00
|
|
|
import React from 'react';
|
2020-08-30 20:45:17 +03:00
|
|
|
import { shallow, ShallowWrapper } from 'enzyme';
|
2018-09-16 13:18:02 +03:00
|
|
|
import { PaginationItem } from 'reactstrap';
|
|
|
|
import Paginator from '../../src/short-urls/Paginator';
|
|
|
|
|
|
|
|
describe('<Paginator />', () => {
|
2020-08-30 20:45:17 +03:00
|
|
|
let wrapper: ShallowWrapper;
|
2018-09-16 13:18:02 +03:00
|
|
|
|
2020-08-30 20:45:17 +03:00
|
|
|
afterEach(() => wrapper?.unmount());
|
2018-09-16 13:18:02 +03:00
|
|
|
|
|
|
|
it('renders nothing if the number of pages is below 2', () => {
|
|
|
|
wrapper = shallow(<Paginator serverId="abc123" />);
|
|
|
|
expect(wrapper.text()).toEqual('');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders previous, next and the list of pages', () => {
|
|
|
|
const paginator = {
|
|
|
|
currentPage: 1,
|
|
|
|
pagesCount: 5,
|
|
|
|
};
|
|
|
|
const extraPagesPrevNext = 2;
|
|
|
|
const expectedItems = paginator.pagesCount + extraPagesPrevNext;
|
|
|
|
|
|
|
|
wrapper = shallow(<Paginator serverId="abc123" paginator={paginator} />);
|
|
|
|
|
|
|
|
expect(wrapper.find(PaginationItem)).toHaveLength(expectedItems);
|
|
|
|
});
|
|
|
|
});
|