mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
* init react-bootstrap-table2-paginator * add react-bootstrap-table2-paginator as dependency * no container * handle for wrapping pagination component * add style for paginator addon * add story for pagination * implement pagination list * constants maintain in core package * implement sizePerPage dropdown * fix unalign for sizePerPage dropdown and pagination list * allow to return array from render(react@16 new feature) * implement pagination hooks * add story for pagination hooks * fixed dependencies version and upgrade enzyme * Shallow renderer no longer calls componentDidMount because DOM refs are not available * classNames -> className for TextEditor * add tests for pagination * fix react-bootstrap-table can't be resolved in other modules * implement custom page button title * add test for page button title * fix bug when sizePerPageList is an object array * add story for custom pagination * remove necessary component extends * move pagination options to react-bootstrap-table2-paginator * refine pagination stories * implement hideSizePerPage * implement hidePageListOnlyOnePage * fix multiple same key warning * remove help * support start from react@^16
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
import React from 'react';
|
|
import sinon from 'sinon';
|
|
import { shallow } from 'enzyme';
|
|
|
|
import SizePerPageOption from '../src/size-per-page-option';
|
|
|
|
describe('SizePerPageOption', () => {
|
|
let wrapper;
|
|
const text = 'page1';
|
|
const page = 1;
|
|
const onSizePerPageChange = sinon.stub();
|
|
|
|
beforeEach(() => {
|
|
const props = { text, page, onSizePerPageChange };
|
|
wrapper = shallow(
|
|
<SizePerPageOption { ...props } />
|
|
);
|
|
});
|
|
|
|
it('should render SizePerPageOption correctly', () => {
|
|
expect(wrapper.length).toBe(1);
|
|
expect(wrapper.find('.dropdown-item').length).toBe(1);
|
|
expect(wrapper.find(`[data-page=${page}]`).length).toBe(1);
|
|
expect(wrapper.text()).toEqual(text);
|
|
});
|
|
|
|
describe('when MouseDown event happen', () => {
|
|
const preventDefault = sinon.stub();
|
|
beforeEach(() => {
|
|
wrapper.find('a').simulate('mousedown', { preventDefault });
|
|
});
|
|
|
|
it('should calling props.onSizePerPageChange correctly', () => {
|
|
expect(preventDefault.calledOnce).toBeTruthy();
|
|
expect(onSizePerPageChange.calledOnce).toBeTruthy();
|
|
expect(onSizePerPageChange.calledWith(page)).toBeTruthy();
|
|
});
|
|
});
|
|
});
|