Skip to content

Commit 77571ea

Browse files
committed
test: update snapshot
1 parent 96e96fb commit 77571ea

17 files changed

Lines changed: 251 additions & 3428 deletions

package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
"compile": "father build && lessc assets/index.less assets/index.css",
4141
"deploy": "npm run docs:build && npm run docs:deploy",
4242
"prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"",
43-
"test": "vitest --watch false",
44-
"coverage": "vitest run --coverage",
43+
"test": "rc-test",
44+
"coverage": "rc-test --coverage",
4545
"prepublishOnly": "npm run compile && rc-np",
4646
"lint": "eslint src/ --ext .tsx,.ts",
4747
"tsc": "tsc -p tsconfig.json --noEmit",
@@ -71,8 +71,6 @@
7171
"@types/responselike": "^1.0.0",
7272
"@types/styled-components": "^5.1.32",
7373
"@umijs/fabric": "^4.0.1",
74-
"@vitest/coverage-v8": "^2.0.5",
75-
"cheerio": "1.0.0-rc.12",
7674
"cross-env": "^7.0.0",
7775
"dumi": "^2.1.3",
7876
"enzyme": "^3.1.0",
@@ -93,6 +91,7 @@
9391
"rc-animate": "^3.0.0",
9492
"rc-dropdown": "~4.0.1",
9593
"rc-menu": "~9.13.0",
94+
"rc-test": "^7.1.2",
9695
"rc-tooltip": "^6.2.0",
9796
"react": "^16.0.0",
9897
"react-dnd": "^2.5.4",
@@ -103,8 +102,7 @@
103102
"react-window": "^1.8.5",
104103
"regenerator-runtime": "^0.14.0",
105104
"styled-components": "^6.1.1",
106-
"typescript": "~5.7.2",
107-
"vitest": "^2.0.5"
105+
"typescript": "~5.7.2"
108106
},
109107
"lint-staged": {
110108
"**/*.{js,jsx,tsx,ts,md,json}": [

tests/Deprecated.spec.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe('Table.Deprecated', () => {
77
let errorSpy;
88

99
beforeAll(() => {
10-
errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
10+
errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
1111
});
1212

1313
beforeEach(() => {
@@ -34,7 +34,7 @@ describe('Table.Deprecated', () => {
3434
removedProp => {
3535
it(`warning for '${removedProp}'`, () => {
3636
const props = {
37-
[removedProp]: vi.fn(),
37+
[removedProp]: jest.fn(),
3838
};
3939
mount(<Table {...props} />);
4040

tests/ExpandRow.spec.jsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('Table.Expand', () => {
2323

2424
it('renders expand row correctly', () => {
2525
resetWarned();
26-
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
26+
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
2727
const wrapper = mount(createTable({ expandedRowRender }));
2828
expect(wrapper.find('tbody tr')).toHaveLength(2);
2929
expect(errorSpy).toHaveBeenCalledWith(
@@ -33,7 +33,7 @@ describe('Table.Expand', () => {
3333
});
3434

3535
it('pass proper parameters to expandedRowRender', () => {
36-
const rowRender = vi.fn(() => <div>expanded row</div>);
36+
const rowRender = jest.fn(() => <div>expanded row</div>);
3737
const expandableProps = props => ({ expandable: { expandedRowRender: rowRender, ...props } });
3838
const wrapper = mount(createTable(expandableProps()));
3939
wrapper.setProps(expandableProps({ expandedRowKeys: [0] }));
@@ -263,7 +263,7 @@ describe('Table.Expand', () => {
263263
describe('config expand column index', () => {
264264
it('not show EXPAND_COLUMN if expandable is false', () => {
265265
resetWarned();
266-
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
266+
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
267267

268268
const wrapper = mount(
269269
createTable({
@@ -281,7 +281,7 @@ describe('Table.Expand', () => {
281281

282282
it('renders expand icon to the specify column', () => {
283283
resetWarned();
284-
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
284+
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
285285

286286
const wrapper = mount(
287287
createTable({
@@ -318,7 +318,7 @@ describe('Table.Expand', () => {
318318

319319
it('de-duplicate of EXPAND_COLUMN', () => {
320320
resetWarned();
321-
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
321+
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
322322

323323
const wrapper = mount(
324324
createTable({
@@ -431,7 +431,7 @@ describe('Table.Expand', () => {
431431
});
432432

433433
it('renders expend row class correctly', () => {
434-
const expandedRowClassName = vi.fn().mockReturnValue('expand-row-test-class-name');
434+
const expandedRowClassName = jest.fn().mockReturnValue('expand-row-test-class-name');
435435
const wrapper = mount(
436436
createTable({
437437
expandable: {
@@ -461,7 +461,7 @@ describe('Table.Expand', () => {
461461
});
462462

463463
it('renders expend row class correctly using children without expandedRowRender', () => {
464-
const expandedRowClassName = vi.fn().mockReturnValue('expand-row-test-class-name');
464+
const expandedRowClassName = jest.fn().mockReturnValue('expand-row-test-class-name');
465465

466466
const _data = [{ ...sampleData[0], children: [sampleData[1]] }];
467467

@@ -495,7 +495,7 @@ describe('Table.Expand', () => {
495495
});
496496

497497
it('fires expand change event', () => {
498-
const onExpand = vi.fn();
498+
const onExpand = jest.fn();
499499
const wrapper = mount(
500500
createTable({
501501
expandable: {
@@ -512,7 +512,7 @@ describe('Table.Expand', () => {
512512
});
513513

514514
it('fires onExpandedRowsChange event', () => {
515-
const onExpandedRowsChange = vi.fn();
515+
const onExpandedRowsChange = jest.fn();
516516
const wrapper = mount(
517517
createTable({
518518
expandedRowRender,
@@ -537,7 +537,7 @@ describe('Table.Expand', () => {
537537
});
538538

539539
it('expandRowByClick', () => {
540-
const onExpand = vi.fn();
540+
const onExpand = jest.fn();
541541
const wrapper = mount(
542542
createTable({
543543
expandable: {
@@ -597,7 +597,7 @@ describe('Table.Expand', () => {
597597
// https://github.com/ant-design/ant-design/issues/23894
598598
it('should be collapsible when use `expandIcon` & `expandRowByClick`', () => {
599599
const data = [{ key: 0, name: 'Lucy', age: 27 }];
600-
const onExpand = vi.fn();
600+
const onExpand = jest.fn();
601601
const wrapper = mount(
602602
createTable({
603603
expandable: {
@@ -625,7 +625,7 @@ describe('Table.Expand', () => {
625625
// https://github.com/ant-design/ant-design/issues/23894
626626
it('should be collapsible when `expandRowByClick` without custom `expandIcon`', () => {
627627
const data = [{ key: 0, name: 'Lucy', age: 27 }];
628-
const onExpand = vi.fn();
628+
const onExpand = jest.fn();
629629
const wrapper = mount(
630630
createTable({
631631
expandable: {
@@ -646,7 +646,7 @@ describe('Table.Expand', () => {
646646

647647
it('should be collapsible when `expandRowByClick` with custom `expandIcon` and event.stopPropagation', () => {
648648
const data = [{ key: 0, name: 'Lucy', age: 27 }];
649-
const onExpand = vi.fn();
649+
const onExpand = jest.fn();
650650
const wrapper = mount(
651651
createTable({
652652
expandable: {
@@ -676,7 +676,7 @@ describe('Table.Expand', () => {
676676

677677
it('support invalid expandIcon', () => {
678678
const data = [{ key: 0, name: 'Lucy', age: 27 }];
679-
const onExpand = vi.fn();
679+
const onExpand = jest.fn();
680680
const wrapper = mount(
681681
createTable({
682682
expandable: {
@@ -693,7 +693,7 @@ describe('Table.Expand', () => {
693693

694694
it('warning for use `expandedRowRender` and nested table in the same time', () => {
695695
resetWarned();
696-
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
696+
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
697697
mount(createTable({ expandedRowRender, data: [{ children: [] }] }));
698698
expect(errorSpy).toHaveBeenCalledWith(
699699
'Warning: `expandedRowRender` should not use with nested Table',
@@ -702,7 +702,7 @@ describe('Table.Expand', () => {
702702
});
703703

704704
it('should only trigger once', () => {
705-
const expandedRowRender = vi.fn(() => <p>extra data</p>);
705+
const expandedRowRender = jest.fn(() => <p>extra data</p>);
706706
render(
707707
createTable({
708708
expandable: {

tests/FixedColumn.spec.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function triggerResize(ele: HTMLElement) {
1515
describe('Table.FixedColumn', () => {
1616
let domSpy;
1717
beforeEach(() => {
18-
vi.useFakeTimers();
18+
jest.useFakeTimers();
1919
});
2020
beforeAll(() => {
2121
domSpy = spyElementPrototypes(HTMLElement, {
@@ -76,7 +76,7 @@ describe('Table.FixedColumn', () => {
7676
{ name: 'without data', data: [] },
7777
].forEach(({ name, data: testData }) => {
7878
it(`${scrollName} - ${name}`, async () => {
79-
vi.useFakeTimers();
79+
jest.useFakeTimers();
8080
const wrapper = mount(<Table columns={columns} data={testData} scroll={scroll} />);
8181

8282
act(() => {
@@ -97,7 +97,7 @@ describe('Table.FixedColumn', () => {
9797
});
9898
await safeAct(wrapper);
9999
expect(wrapper.render()).toMatchSnapshot();
100-
vi.useRealTimers();
100+
jest.useRealTimers();
101101
});
102102
});
103103
});
@@ -272,7 +272,7 @@ describe('Table.FixedColumn', () => {
272272
});
273273

274274
await act(async () => {
275-
vi.runAllTimers();
275+
jest.runAllTimers();
276276
await Promise.resolve();
277277
});
278278

tests/FixedHeader.spec.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('Table.FixedHeader', () => {
1717
});
1818

1919
beforeEach(() => {
20-
vi.useFakeTimers();
20+
jest.useFakeTimers();
2121
visible = true;
2222
});
2323

@@ -81,7 +81,7 @@ describe('Table.FixedHeader', () => {
8181
expect(wrapper.find('colgroup col').at(0).props().style.width).toEqual(200);
8282
expect(wrapper.find('colgroup col').at(1).props().style.width).toEqual(100);
8383

84-
vi.useRealTimers();
84+
jest.useRealTimers();
8585
});
8686

8787
it('INTERNAL_COL_DEFINE', async () => {
@@ -201,15 +201,15 @@ describe('Table.FixedHeader', () => {
201201
]);
202202

203203
act(() => {
204-
vi.runAllTimers();
204+
jest.runAllTimers();
205205
wrapper.update();
206206
});
207207

208208
expect(wrapper.find('FixedHolder col').first().props().style).toEqual(
209209
expect.objectContaining({ width: 93 }),
210210
);
211211

212-
vi.useRealTimers();
212+
jest.useRealTimers();
213213
});
214214

215215
it('do not mask as ant-table-cell-fix-left-last in nested table parent cell', async () => {

tests/Hover.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('Table.Hover', () => {
4141

4242
it('warning if use `render` for rowSpan', () => {
4343
resetWarned();
44-
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
44+
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
4545

4646
const wrapper = mount(
4747
createTable({

tests/Scroll.spec.jsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ describe('Table.Scroll', () => {
5050
});
5151

5252
it('fire scroll event', () => {
53-
vi.useFakeTimers();
53+
jest.useFakeTimers();
5454
let scrollLeft = 0;
5555
let scrollTop = 0;
5656

57-
const setScrollLeft = vi.fn((_, val) => {
57+
const setScrollLeft = jest.fn((_, val) => {
5858
scrollLeft = val;
5959
});
60-
const setScrollTop = vi.fn((_, val) => {
60+
const setScrollTop = jest.fn((_, val) => {
6161
scrollTop = val;
6262
});
6363

@@ -99,7 +99,7 @@ describe('Table.Scroll', () => {
9999
/>,
100100
);
101101

102-
vi.runAllTimers();
102+
jest.runAllTimers();
103103
// Use `onScroll` directly since simulate not support `currentTarget`
104104
act(() => {
105105
const headerDiv = wrapper.find('div.rc-table-header').instance();
@@ -110,7 +110,7 @@ describe('Table.Scroll', () => {
110110
});
111111

112112
headerDiv.dispatchEvent(wheelEvent);
113-
vi.runAllTimers();
113+
jest.runAllTimers();
114114
});
115115

116116
expect(setScrollLeft).toHaveBeenCalledWith(undefined, 10);
@@ -128,12 +128,12 @@ describe('Table.Scroll', () => {
128128
},
129129
});
130130
});
131-
vi.runAllTimers();
131+
jest.runAllTimers();
132132
expect(setScrollLeft).toHaveBeenCalledWith(undefined, 33);
133133
setScrollLeft.mockReset();
134134

135135
domSpy.mockRestore();
136-
vi.useRealTimers();
136+
jest.useRealTimers();
137137
});
138138

139139
it('trigger inner scrollTo when set `top` 0 after render', () => {

0 commit comments

Comments
 (0)