Skip to content

Commit f7f24bb

Browse files
author
刘欢
committed
refactor: Remove enzyme and switch to RTL testing (1)
1 parent 4928cf3 commit f7f24bb

File tree

11 files changed

+325
-185
lines changed

11 files changed

+325
-185
lines changed

jest.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
module.exports = {
2-
setupFiles: ['./tests/setup.js'],
3-
snapshotSerializers: [require.resolve('enzyme-to-json/serializer')],
2+
setupFiles: ['./tests/setup.js']
43
};

package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"now-build": "npm run docs:build"
4545
},
4646
"dependencies": {
47-
"clsx": "^2.2.1",
47+
"clsx": "^2.1.1",
4848
"@rc-component/resize-observer": "^1.0.0",
4949
"@rc-component/util": "^1.3.0"
5050
},
@@ -53,7 +53,6 @@
5353
"@rc-component/np": "^1.0.3",
5454
"@testing-library/jest-dom": "^5.16.4",
5555
"@testing-library/react": "^14.0.0",
56-
"@types/enzyme": "^3.10.8",
5756
"@types/jest": "^26.0.23",
5857
"@types/node": "^24.8.1",
5958
"@types/react": "^18.0.0",
@@ -62,9 +61,6 @@
6261
"@typescript-eslint/parser": "^5.59.0",
6362
"@umijs/fabric": "^3.0.0",
6463
"dumi": "^2.0.0",
65-
"enzyme": "^3.0.0",
66-
"enzyme-adapter-react-16": "^1.0.1",
67-
"enzyme-to-json": "^3.4.0",
6864
"eslint": "^8.57.0",
6965
"eslint-plugin-jest": "^27.5.1",
7066
"eslint-plugin-unicorn": "^51.0.1",
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`Overflow.Basic customize component 1`] = `
4-
<ul
5-
class="rc-overflow"
6-
>
7-
<li
8-
class="rc-overflow-item"
9-
style="opacity: 1;"
4+
<div>
5+
<ul
6+
class="rc-overflow"
107
>
11-
Label 0
12-
</li>
13-
</ul>
8+
<li
9+
class="rc-overflow-item"
10+
style="opacity: 1;"
11+
>
12+
Label 0
13+
</li>
14+
</ul>
15+
</div>
1416
`;
Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,39 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`Overflow.Invalidate render item 1`] = `
4-
<ul
5-
class=""
6-
>
7-
<li
4+
<div>
5+
<ul
86
class=""
97
>
10-
Label 0
11-
</li>
12-
<li
13-
class=""
14-
>
15-
Label 1
16-
</li>
17-
</ul>
8+
<li
9+
class=""
10+
>
11+
Label 0
12+
</li>
13+
<li
14+
class=""
15+
>
16+
Label 1
17+
</li>
18+
</ul>
19+
</div>
1820
`;
1921

2022
exports[`Overflow.Invalidate render raw 1`] = `
21-
<ul
22-
class=""
23-
>
24-
<li
25-
class=""
26-
>
27-
Label 0
28-
</li>
29-
<li
23+
<div>
24+
<ul
3025
class=""
3126
>
32-
Label 1
33-
</li>
34-
</ul>
27+
<li
28+
class=""
29+
>
30+
Label 0
31+
</li>
32+
<li
33+
class=""
34+
>
35+
Label 1
36+
</li>
37+
</ul>
38+
</div>
3539
`;
Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,39 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`Overflow.Raw HOC usage 1`] = `
4-
<div
5-
class="rc-overflow"
6-
>
4+
<div>
75
<div
8-
class="rc-overflow-item"
9-
style="opacity: 1;"
6+
class="rc-overflow"
107
>
11-
Bamboo
8+
<div
9+
class="rc-overflow-item"
10+
style="opacity: 1;"
11+
>
12+
Bamboo
13+
</div>
1214
</div>
1315
</div>
1416
`;
1517

1618
exports[`Overflow.Raw render node directly 1`] = `
17-
<ul
18-
class="rc-overflow"
19-
>
20-
<li
21-
class="rc-overflow-item"
22-
style="opacity: 1;"
19+
<div>
20+
<ul
21+
class="rc-overflow"
2322
>
24-
Label 0
25-
</li>
26-
</ul>
23+
<li
24+
class="rc-overflow-item"
25+
style="opacity: 1;"
26+
>
27+
Label 0
28+
</li>
29+
</ul>
30+
</div>
2731
`;
2832

2933
exports[`Overflow.Raw safe with item directly 1`] = `
3034
<div>
31-
Bamboo
35+
<div>
36+
Bamboo
37+
</div>
3238
</div>
3339
`;
Lines changed: 106 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,110 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`Overflow.SSR basic 1`] = `
4-
<div
5-
class="rc-overflow"
6-
>
7-
<div
8-
class="rc-overflow-item"
9-
style="opacity:1;order:0"
10-
>
11-
Label 0
12-
</div>
13-
<div
14-
class="rc-overflow-item"
15-
style="opacity:1;order:1"
16-
>
17-
Label 1
18-
</div>
19-
<div
20-
aria-hidden="true"
21-
class="rc-overflow-item rc-overflow-item-rest"
22-
style="opacity:0;height:0;overflow-y:hidden;order:9007199254740991;pointer-events:none;position:absolute"
23-
>
24-
+ 0 ...
25-
</div>
26-
</div>
4+
{
5+
"asFragment": [Function],
6+
"baseElement": <body>
7+
<div>
8+
<div
9+
class="rc-overflow"
10+
>
11+
<div
12+
class="rc-overflow-item"
13+
style="opacity: 1; order: 0;"
14+
>
15+
Label 0
16+
</div>
17+
<div
18+
class="rc-overflow-item"
19+
style="opacity: 1; order: 1;"
20+
>
21+
Label 1
22+
</div>
23+
<div
24+
aria-hidden="true"
25+
class="rc-overflow-item rc-overflow-item-rest"
26+
style="opacity: 0; height: 0px; overflow-y: hidden; order: 9007199254740991; pointer-events: none; position: absolute;"
27+
>
28+
+ 0 ...
29+
</div>
30+
</div>
31+
</div>
32+
</body>,
33+
"container": <div>
34+
<div
35+
class="rc-overflow"
36+
>
37+
<div
38+
class="rc-overflow-item"
39+
style="opacity: 1; order: 0;"
40+
>
41+
Label 0
42+
</div>
43+
<div
44+
class="rc-overflow-item"
45+
style="opacity: 1; order: 1;"
46+
>
47+
Label 1
48+
</div>
49+
<div
50+
aria-hidden="true"
51+
class="rc-overflow-item rc-overflow-item-rest"
52+
style="opacity: 0; height: 0px; overflow-y: hidden; order: 9007199254740991; pointer-events: none; position: absolute;"
53+
>
54+
+ 0 ...
55+
</div>
56+
</div>
57+
</div>,
58+
"debug": [Function],
59+
"findAllByAltText": [Function],
60+
"findAllByDisplayValue": [Function],
61+
"findAllByLabelText": [Function],
62+
"findAllByPlaceholderText": [Function],
63+
"findAllByRole": [Function],
64+
"findAllByTestId": [Function],
65+
"findAllByText": [Function],
66+
"findAllByTitle": [Function],
67+
"findByAltText": [Function],
68+
"findByDisplayValue": [Function],
69+
"findByLabelText": [Function],
70+
"findByPlaceholderText": [Function],
71+
"findByRole": [Function],
72+
"findByTestId": [Function],
73+
"findByText": [Function],
74+
"findByTitle": [Function],
75+
"getAllByAltText": [Function],
76+
"getAllByDisplayValue": [Function],
77+
"getAllByLabelText": [Function],
78+
"getAllByPlaceholderText": [Function],
79+
"getAllByRole": [Function],
80+
"getAllByTestId": [Function],
81+
"getAllByText": [Function],
82+
"getAllByTitle": [Function],
83+
"getByAltText": [Function],
84+
"getByDisplayValue": [Function],
85+
"getByLabelText": [Function],
86+
"getByPlaceholderText": [Function],
87+
"getByRole": [Function],
88+
"getByTestId": [Function],
89+
"getByText": [Function],
90+
"getByTitle": [Function],
91+
"queryAllByAltText": [Function],
92+
"queryAllByDisplayValue": [Function],
93+
"queryAllByLabelText": [Function],
94+
"queryAllByPlaceholderText": [Function],
95+
"queryAllByRole": [Function],
96+
"queryAllByTestId": [Function],
97+
"queryAllByText": [Function],
98+
"queryAllByTitle": [Function],
99+
"queryByAltText": [Function],
100+
"queryByDisplayValue": [Function],
101+
"queryByLabelText": [Function],
102+
"queryByPlaceholderText": [Function],
103+
"queryByRole": [Function],
104+
"queryByTestId": [Function],
105+
"queryByText": [Function],
106+
"queryByTitle": [Function],
107+
"rerender": [Function],
108+
"unmount": [Function],
109+
}
27110
`;

0 commit comments

Comments
 (0)