mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 17:40:23 +03:00
Created PaginationDropdown test
This commit is contained in:
parent
b462169e1e
commit
27e3d65143
1 changed files with 35 additions and 0 deletions
35
test/utils/PaginationDropdown.test.tsx
Normal file
35
test/utils/PaginationDropdown.test.tsx
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
import { shallow, ShallowWrapper } from 'enzyme';
|
||||||
|
import { DropdownItem } from 'reactstrap';
|
||||||
|
import PaginationDropdown from '../../src/utils/PaginationDropdown';
|
||||||
|
|
||||||
|
describe('<PaginationDropdown />', () => {
|
||||||
|
const setValue = jest.fn();
|
||||||
|
let wrapper: ShallowWrapper;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
wrapper = shallow(<PaginationDropdown ranges={[ 10, 50, 100, 200 ]} value={50} setValue={setValue} />);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(jest.clearAllMocks);
|
||||||
|
afterEach(() => wrapper?.unmount());
|
||||||
|
|
||||||
|
test('expected amount of items is rendered', () => {
|
||||||
|
const items = wrapper.find(DropdownItem);
|
||||||
|
|
||||||
|
expect(items).toHaveLength(6);
|
||||||
|
});
|
||||||
|
|
||||||
|
test.each([
|
||||||
|
[ 0, 10 ],
|
||||||
|
[ 1, 50 ],
|
||||||
|
[ 2, 100 ],
|
||||||
|
[ 3, 200 ],
|
||||||
|
[ 5, Infinity ],
|
||||||
|
])('expected value is set when an item is clicked', (index, expectedValue) => {
|
||||||
|
const item = wrapper.find(DropdownItem).at(index);
|
||||||
|
|
||||||
|
expect(setValue).not.toHaveBeenCalled();
|
||||||
|
item.simulate('click');
|
||||||
|
expect(setValue).toHaveBeenCalledWith(expectedValue);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in a new issue