Skip to content

Commit df3320f

Browse files
committed
chore: use testing-library dom events
1 parent 1151a38 commit df3320f

5 files changed

Lines changed: 53 additions & 20 deletions

File tree

package.json

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,32 @@
5050
"clsx": "^2.1.1"
5151
},
5252
"devDependencies": {
53+
"@babel/eslint-parser": "^7.29.7",
54+
"@babel/eslint-plugin": "^7.29.7",
55+
"@eslint/eslintrc": "^3.3.5",
56+
"@eslint/js": "^9.39.4",
5357
"@rc-component/father-plugin": "^2.2.0",
5458
"@rc-component/np": "^1.0.4",
5559
"@swc-node/jest": "^1.5.5",
60+
"@testing-library/dom": "^10.4.1",
5661
"@testing-library/jest-dom": "^6.9.1",
5762
"@testing-library/react": "^16.3.2",
5863
"@types/jest": "^30.0.0",
5964
"@types/node": "^26.0.1",
6065
"@types/react": "^19.2.17",
6166
"@types/react-dom": "^19.2.3",
6267
"@types/responselike": "^1.0.3",
68+
"@typescript-eslint/eslint-plugin": "^8.62.0",
69+
"@typescript-eslint/parser": "^8.62.0",
6370
"@umijs/fabric": "^4.0.1",
6471
"@umijs/test": "^4.6.68",
6572
"dumi": "^2.4.35",
6673
"eslint": "^9.39.4",
74+
"eslint-config-prettier": "^10.1.8",
75+
"eslint-plugin-jest": "^29.15.3",
76+
"eslint-plugin-react": "^7.37.5",
77+
"eslint-plugin-react-hooks": "^7.1.1",
78+
"eslint-plugin-unicorn": "^65.0.1",
6779
"father": "^4.6.23",
6880
"gh-pages": "^6.3.0",
6981
"glob": "^13.0.6",
@@ -77,18 +89,7 @@
7789
"react-dom": "^19.2.7",
7890
"regenerator-runtime": "^0.14.1",
7991
"ts-node": "^10.9.1",
80-
"typescript": "^6.0.3",
81-
"@eslint/eslintrc": "^3.3.5",
82-
"@eslint/js": "^9.39.4",
83-
"eslint-plugin-react": "^7.37.5",
84-
"eslint-plugin-react-hooks": "^7.1.1",
85-
"eslint-config-prettier": "^10.1.8",
86-
"@babel/eslint-parser": "^7.29.7",
87-
"@babel/eslint-plugin": "^7.29.7",
88-
"@typescript-eslint/eslint-plugin": "^8.62.0",
89-
"@typescript-eslint/parser": "^8.62.0",
90-
"eslint-plugin-jest": "^29.15.3",
91-
"eslint-plugin-unicorn": "^65.0.1"
92+
"typescript": "^6.0.3"
9293
},
9394
"peerDependencies": {
9495
"react": ">=16.9.0",

tests/click.test.tsx

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { fireEvent } from '@testing-library/dom';
12
import * as React from 'react';
2-
import { render, fireEvent, act } from '@testing-library/react';
3+
import { render, act } from '@testing-library/react';
34
import InputNumber, { InputNumberProps } from '../src';
45
import { KeyCode } from '@rc-component/util';
56

@@ -43,9 +44,23 @@ describe('InputNumber.Click', () => {
4344
}
4445

4546
describe('basic work', () => {
46-
testInputNumber('up button', { defaultValue: 10 }, '.rc-input-number-action-up', 11, 'up', 'handler');
47+
testInputNumber(
48+
'up button',
49+
{ defaultValue: 10 },
50+
'.rc-input-number-action-up',
51+
11,
52+
'up',
53+
'handler',
54+
);
4755

48-
testInputNumber('down button', { value: 10 }, '.rc-input-number-action-down', 9, 'down', 'handler');
56+
testInputNumber(
57+
'down button',
58+
{ value: 10 },
59+
'.rc-input-number-action-down',
60+
9,
61+
'down',
62+
'handler',
63+
);
4964
});
5065

5166
describe('empty input', () => {
@@ -55,9 +70,23 @@ describe('InputNumber.Click', () => {
5570
});
5671

5772
describe('empty with min & max', () => {
58-
testInputNumber('up button', { min: 6, max: 10 }, '.rc-input-number-action-up', 6, 'up', 'handler');
73+
testInputNumber(
74+
'up button',
75+
{ min: 6, max: 10 },
76+
'.rc-input-number-action-up',
77+
6,
78+
'up',
79+
'handler',
80+
);
5981

60-
testInputNumber('down button', { min: 6, max: 10 }, '.rc-input-number-action-down', 6, 'down', 'handler');
82+
testInputNumber(
83+
'down button',
84+
{ min: 6, max: 10 },
85+
'.rc-input-number-action-down',
86+
6,
87+
'down',
88+
'handler',
89+
);
6190
});
6291

6392
describe('null with min & max', () => {

tests/focus.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { fireEvent } from '@testing-library/dom';
12
import { spyElementPrototypes } from '@rc-component/util';
2-
import { fireEvent, render } from '@testing-library/react';
3+
import { render } from '@testing-library/react';
34
import React from 'react';
45
import InputNumber, { InputNumberRef } from '../src';
56

tests/precision.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import { fireEvent } from '@testing-library/dom';
12
import { KeyCode } from '@rc-component/util';
23
import '@testing-library/jest-dom';
3-
import { fireEvent, render } from '@testing-library/react';
4+
import { render } from '@testing-library/react';
45
import React from 'react';
56
import InputNumber from '../src';
67

tests/props.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import { fireEvent } from '@testing-library/dom';
12
import { KeyCode } from '@rc-component/util';
23
import '@testing-library/jest-dom';
3-
import { fireEvent, render } from '@testing-library/react';
4+
import { render } from '@testing-library/react';
45
import React from 'react';
56
import type { ValueType } from '../src';
67
import InputNumber from '../src';

0 commit comments

Comments
 (0)