Skip to content

Commit b2df747

Browse files
authored
Merge 9d7c5b3 into b002aac
2 parents b002aac + 9d7c5b3 commit b2df747

File tree

4 files changed

+59
-3
lines changed

4 files changed

+59
-3
lines changed

docs/examples/simple.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import Pagination from 'rc-pagination';
3+
import Select from 'rc-select';
34
import '../../assets/index.less';
45

56
export default () => (
@@ -12,5 +13,13 @@ export default () => (
1213
total={50}
1314
showTotal={(total) => `Total ${total} items`}
1415
/>
16+
<br />
17+
<Pagination
18+
simple
19+
defaultCurrent={1}
20+
total={50}
21+
showSizeChanger
22+
selectComponentClass={Select}
23+
/>
1524
</>
1625
);

src/Pagination.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,19 @@ class Pagination extends React.Component<PaginationProps, PaginationState> {
590590
>
591591
{this.renderNext(nextPage)}
592592
</li>
593-
{gotoButton}
593+
<Options
594+
disabled={disabled}
595+
locale={locale}
596+
rootPrefixCls={prefixCls}
597+
selectComponentClass={selectComponentClass}
598+
selectPrefixCls={selectPrefixCls}
599+
changeSize={this.getShowSizeChanger() ? this.changePageSize : null}
600+
current={current}
601+
pageSize={pageSize}
602+
pageSizeOptions={pageSizeOptions}
603+
quickGo={this.shouldDisplayQuickJumper() ? this.handleChange : null}
604+
goButton={gotoButton}
605+
/>
594606
</ul>
595607
);
596608
}

tests/jumper.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import { mount } from 'enzyme';
32
import Pagination from '../src';
43

@@ -99,7 +98,7 @@ describe('simple quick jumper', () => {
9998
});
10099

101100
it('should quick jump to expect page', () => {
102-
const quickJumper = wrapper.find('.rc-pagination-simple');
101+
const quickJumper = wrapper.find('.rc-pagination-options-quick-jumper');
103102
const input = quickJumper.find('input');
104103
const goButton = quickJumper.find('.go-button');
105104
input.simulate('change', { target: { value: '2' } });

tests/simple.test.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useState } from 'react';
22
import { mount } from 'enzyme';
3+
import Select from 'rc-select';
34
import Pagination from '../src';
45

56
describe('simple Pagination', () => {
@@ -84,4 +85,39 @@ describe('simple Pagination', () => {
8485
expect(input.getDOMNode().value).toBe('3');
8586
expect(component.state().current).toBe(3);
8687
});
88+
89+
it('should merge custom pageSize to pageSizeOptions', () => {
90+
const wrapper = mount(
91+
<Pagination
92+
simple
93+
total={500}
94+
pageSize={15}
95+
showSizeChanger
96+
selectComponentClass={Select}
97+
/>,
98+
);
99+
wrapper.find(Select).find('input').simulate('mousedown');
100+
expect(wrapper.find(Select).find('.rc-select-item').length).toBe(5);
101+
});
102+
103+
it('should onChange called when pageSize change', () => {
104+
const onChange = jest.fn();
105+
const wrapper = mount(
106+
<Pagination
107+
simple
108+
selectComponentClass={Select}
109+
onChange={onChange}
110+
total={500}
111+
defaultPageSize={20}
112+
/>,
113+
);
114+
wrapper.find(Select).find('input').simulate('mousedown');
115+
expect(wrapper.find(Select).find('.rc-select-item').at(2).text()).toBe(
116+
'50 条/页',
117+
);
118+
const pageSize1 = wrapper.find(Select).find('.rc-select-item').at(0);
119+
pageSize1.simulate('click');
120+
expect(onChange).toBeCalled();
121+
expect(onChange).toHaveBeenLastCalledWith(1, 10);
122+
});
87123
});

0 commit comments

Comments
 (0)