diff --git a/src/Options.tsx b/src/Options.tsx index 9608697c..0517c556 100644 --- a/src/Options.tsx +++ b/src/Options.tsx @@ -158,7 +158,7 @@ const Options: React.FC = (props) => { {locale.jump_to} 页 @@ -1874,7 +1874,7 @@ exports[`Example jumper 1`] = ` 页 @@ -2234,7 +2234,7 @@ exports[`Example jumperWithGoButton 1`] = ` 跳至 页 @@ -2303,7 +2303,7 @@ exports[`Example jumperWithGoButton 1`] = ` 跳至 页 @@ -2776,7 +2776,7 @@ exports[`Example locale 1`] = ` Go to Page @@ -4020,7 +4020,7 @@ exports[`Example simple 1`] = ` 跳至 页 diff --git a/tests/__snapshots__/options.test.tsx.snap b/tests/__snapshots__/options.test.tsx.snap index c241a318..c2362d7d 100644 --- a/tests/__snapshots__/options.test.tsx.snap +++ b/tests/__snapshots__/options.test.tsx.snap @@ -50,7 +50,7 @@ exports[`Options should render correctly 1`] = ` 跳至 页 diff --git a/tests/__snapshots__/simple.test.tsx.snap b/tests/__snapshots__/simple.test.tsx.snap index f2bcb51a..5a459978 100644 --- a/tests/__snapshots__/simple.test.tsx.snap +++ b/tests/__snapshots__/simple.test.tsx.snap @@ -7,7 +7,7 @@ exports[`simple Pagination props: showQuickJumper should render normally quick-j 跳至 页 @@ -21,7 +21,7 @@ exports[`simple Pagination props: showQuickJumper should render normally quick-j 跳至 页 @@ -49,7 +49,7 @@ exports[`simple Pagination props: showQuickJumper should render normally quick-j 跳至 页 diff --git a/tests/jumper.test.tsx b/tests/jumper.test.tsx index 39f0f5fe..ae01ee6a 100644 --- a/tests/jumper.test.tsx +++ b/tests/jumper.test.tsx @@ -51,7 +51,7 @@ describe('Pagination with jumper', () => { relatedTarget.className = 'rc-pagination-item-link'; fireEvent.blur(input, { relatedTarget }); - expect(input).toHaveValue(''); + expect(input).toHaveValue(null); expect(onChange).not.toHaveBeenCalled(); }); @@ -64,7 +64,7 @@ describe('Pagination with jumper', () => { relatedTarget.className = 'rc-pagination-item'; fireEvent.blur(input, { relatedTarget }); - expect(input).toHaveValue(''); + expect(input).toHaveValue(null); expect(onChange).not.toHaveBeenCalled(); }); @@ -271,3 +271,43 @@ describe('simple quick jumper', () => { ).toBeFalsy(); }); }); + +describe('inputType number', () => { + it('should accept only number', () => { + const onChange = jest.fn(); + const { container } = render( + , + ); + const quickJumper = container.querySelector( + '.rc-pagination-options-quick-jumper', + ); + const input = quickJumper.querySelector('input'); + fireEvent.change(input, { target: { value: '42' } }); + expect(input.value).toBe('42'); + }); + + it('should not accept non-number', () => { + const onChange = jest.fn(); + const { container } = render( + , + ); + const quickJumper = container.querySelector( + '.rc-pagination-options-quick-jumper', + ); + const input = quickJumper.querySelector('input'); + fireEvent.change(input, { target: { value: 'abc' } }); + expect(input.value).toBe(''); + }); +});