Skip to content

Commit c7628b3

Browse files
committed
test: clean up
1 parent 3601541 commit c7628b3

File tree

2 files changed

+17
-33
lines changed

2 files changed

+17
-33
lines changed

tests/FixedColumn.spec.tsx

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -208,22 +208,6 @@ describe('Table.FixedColumn', () => {
208208
expect(container.firstChild).toMatchSnapshot();
209209
});
210210

211-
it('has correct scroll classNames when table direction is RTL', () => {
212-
const { container } = render(<Table columns={columns} data={data} direction="rtl" />);
213-
214-
expect(container.querySelector('.rc-table')?.classList.contains('rc-table-rtl')).toBeTruthy();
215-
216-
expect(container.querySelector('.rc-table-row')?.querySelector('.rc-table-cell')).toHaveClass(
217-
'rc-table-cell-fix-right',
218-
);
219-
220-
expect(
221-
container.querySelector('.rc-table-row')?.querySelectorAll('.rc-table-cell')[
222-
container.querySelector('.rc-table-row')?.querySelectorAll('.rc-table-cell').length - 1
223-
],
224-
).toHaveClass('rc-table-cell-fix-left');
225-
});
226-
227211
it('not break measure count', async () => {
228212
const { container, rerender } = render(
229213
<Table columns={columns.slice(0, 5)} data={data} scroll={{ x: 1000 }} />,
@@ -240,17 +224,15 @@ describe('Table.FixedColumn', () => {
240224
expect(container.querySelectorAll('.rc-table-measure-row td')).toHaveLength(4);
241225
});
242226

243-
it('when all columns fixed left,cell should has classname rc-table-cell-fix-left-all', async () => {
227+
it('when all columns fixed left, should not add fixed className', async () => {
244228
const { container } = render(
245229
<Table columns={columns.slice(0, 2)} data={data} scroll={{ x: 1000 }} />,
246230
);
247-
248231
await act(async () => {
249232
vi.runAllTimers();
250233
await Promise.resolve();
251234
});
252-
253-
expect(container.querySelectorAll('.rc-table-cell-fix-left-all')).toHaveLength(10);
235+
expect(container.querySelector('.rc-table-cell-fix')).toBeFalsy();
254236
});
255237

256238
describe('cross fixed support', () => {
@@ -274,9 +256,13 @@ describe('Table.FixedColumn', () => {
274256
await Promise.resolve();
275257
});
276258

277-
expect(container.querySelectorAll('tbody .rc-table-cell-fix-left')).toHaveLength(2);
278-
expect(container.querySelectorAll('thead th')[1]).toHaveStyle({ left: '0px' });
279-
expect(container.querySelectorAll('thead th')[2]).toHaveStyle({ left: '1000px' });
259+
expect(container.querySelectorAll('tbody .rc-table-cell-fix-start')).toHaveLength(2);
260+
expect(container.querySelectorAll('thead th')[1]).toHaveStyle({
261+
'inset-inline-start': '0',
262+
});
263+
expect(container.querySelectorAll('thead th')[2]).toHaveStyle({
264+
'inset-inline-start': '1000px',
265+
});
280266
});
281267
});
282268
describe('components.table by sticky', () => {
@@ -295,13 +281,11 @@ describe('Table.FixedColumn', () => {
295281
});
296282
it('shadow should display correctly', async () => {
297283
const { container, rerender } = render(<RowColSpanWithFixed />);
298-
expect(container.querySelectorAll('.rc-table-cell-fix-left-last').length).toBe(104);
299-
expect(container.querySelectorAll('.rc-table-cell-fix-right-first').length).toBe(101);
300-
expect(container).toMatchSnapshot();
284+
expect(container.querySelectorAll('.rc-table-cell-fix-start-shadow').length).toBe(104);
285+
expect(container.querySelectorAll('.rc-table-cell-fix-end-shadow').length).toBe(101);
301286
rerender(<RowColSpanWithFixed2 />);
302-
expect(container.querySelectorAll('.rc-table-cell-fix-left-last').length).toBe(4);
303-
expect(container.querySelectorAll('.rc-table-cell-fix-right-first').length).toBe(4);
304-
expect(container).toMatchSnapshot();
287+
expect(container.querySelectorAll('.rc-table-cell-fix-start-shadow').length).toBe(4);
288+
expect(container.querySelectorAll('.rc-table-cell-fix-end-shadow').length).toBe(4);
305289
});
306290

307291
it('shadow should be shown when there are columns where fixed is false', async () => {
@@ -331,9 +315,9 @@ describe('Table.FixedColumn', () => {
331315
]}
332316
/>,
333317
);
334-
expect(container.querySelectorAll('.rc-table-cell-fix-left-last').length).toBe(101);
335-
expect(container.querySelectorAll('.rc-table-cell-fix-right-first').length).toBe(101);
336-
expect(container).toMatchSnapshot();
318+
319+
expect(container.querySelectorAll('.rc-table-cell-fix-end-shadow')).toHaveLength(101);
320+
expect(container.querySelectorAll('.rc-table-cell-fix-start-shadow')).toHaveLength(101);
337321
});
338322

339323
it('right shadow should be shown when scrollX is less than the sum of the widths of all columns', async () => {

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"@@/*": [".dumi/tmp/*"],
1313
"rc-table": ["src/index.ts"]
1414
},
15-
"types": ["@testing-library/jest-dom"]
15+
"types": ["vitest/globals", "@testing-library/jest-dom"]
1616
},
1717
"include": [".dumirc.ts", "**/*.ts", "**/*.tsx", "tests/__mocks__/shadowTest.tsx"],
1818
"exclude": ["./vitest.config.ts"]

0 commit comments

Comments
 (0)