diff --git a/tests/Table.spec.jsx b/tests/Table.spec.jsx
index 39ecc5e1b..1c62fe31f 100644
--- a/tests/Table.spec.jsx
+++ b/tests/Table.spec.jsx
@@ -1,11 +1,11 @@
import { mount } from 'enzyme';
import { resetWarned } from 'rc-util/lib/warning';
import React from 'react';
+import { VariableSizeGrid as Grid } from 'react-window';
import Table, { INTERNAL_COL_DEFINE } from '../src';
import BodyRow from '../src/Body/BodyRow';
import Cell from '../src/Cell';
import { INTERNAL_HOOKS } from '../src/constant';
-import { VariableSizeGrid as Grid } from "react-window";
describe('Table.Basic', () => {
const data = [
@@ -684,22 +684,6 @@ describe('Table.Basic', () => {
);
errSpy.mockRestore();
});
-
- it('without scroll', () => {
- resetWarned();
- const errSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
- mount(
- createTable({
- components: {
- body: () =>
Bamboo
,
- },
- }),
- );
- expect(errSpy).toHaveBeenCalledWith(
- 'Warning: `components.body` with render props is only work on `scroll.y`.',
- );
- errSpy.mockRestore();
- });
});
it('without warning - columns is empty', () => {
@@ -1222,52 +1206,54 @@ describe('Table.Basic', () => {
const width = 150;
const noChildColLen = 4;
const ChildColLen = 4;
- const buildChildDataIndex = (n) => `col${n}`;
+ const buildChildDataIndex = n => `col${n}`;
const columns = Array.from({ length: noChildColLen }, (_, i) => ({
title: `第 ${i} 列`,
dataIndex: buildChildDataIndex(i),
width,
- })).concat(Array.from({ length: ChildColLen }, (_, i) => ({
- title: `第 ${i} 分组`,
- dataIndex: `parentCol${i}`,
- width: width * 2,
- children: [
- {
- title: `第 ${noChildColLen + i} 列`,
- dataIndex: buildChildDataIndex(noChildColLen + i),
- width,
- },
- {
- title: `第 ${noChildColLen + 1 + i} 列`,
- dataIndex: buildChildDataIndex(noChildColLen + 1 + i),
- width,
- },
- ]
- })));
+ })).concat(
+ Array.from({ length: ChildColLen }, (_, i) => ({
+ title: `第 ${i} 分组`,
+ dataIndex: `parentCol${i}`,
+ width: width * 2,
+ children: [
+ {
+ title: `第 ${noChildColLen + i} 列`,
+ dataIndex: buildChildDataIndex(noChildColLen + i),
+ width,
+ },
+ {
+ title: `第 ${noChildColLen + 1 + i} 列`,
+ dataIndex: buildChildDataIndex(noChildColLen + 1 + i),
+ width,
+ },
+ ],
+ })),
+ );
const data = Array.from({ length: 10000 }, (_, r) => {
const colLen = noChildColLen + ChildColLen * 2;
const record = {};
- for (let c = 0; c < colLen; c ++) {
- record[buildChildDataIndex(c)] = `r${r}, c${c}`
+ for (let c = 0; c < colLen; c++) {
+ record[buildChildDataIndex(c)] = `r${r}, c${c}`;
}
return record;
- })
- const Demo = (props) => {
+ });
+ const Demo = props => {
const gridRef = React.useRef();
const [connectObject] = React.useState(() => {
const obj = {};
- Object.defineProperty(obj, "scrollLeft", {
+ Object.defineProperty(obj, 'scrollLeft', {
get: () => {
if (gridRef.current) {
return gridRef.current?.state?.scrollLeft;
}
return null;
},
- set: (scrollLeft) => {
+ set: scrollLeft => {
if (gridRef.current) {
gridRef.current.scrollTo({ scrollLeft });
}
- }
+ },
});
return obj;
@@ -1276,7 +1262,7 @@ describe('Table.Basic', () => {
React.useEffect(() => {
gridRef.current.resetAfterIndices({
columnIndex: 0,
- shouldForceUpdate: false
+ shouldForceUpdate: false,
});
}, []);
@@ -1287,11 +1273,9 @@ describe('Table.Basic', () => {
ref={gridRef}
className="virtual-grid"
columnCount={columns.length}
- columnWidth={(index) => {
+ columnWidth={index => {
const { width } = columns[index];
- return index === columns.length - 1
- ? width - scrollbarSize - 1
- : width;
+ return index === columns.length - 1 ? width - scrollbarSize - 1 : width;
}}
height={300}
rowCount={rawData.length}
@@ -1303,7 +1287,9 @@ describe('Table.Basic', () => {
>
{({ columnIndex, rowIndex, style }) => (
r{rowIndex}, c{columnIndex}
@@ -1321,12 +1307,17 @@ describe('Table.Basic', () => {
data={props.data}
scroll={{ y: 300, x: 300 }}
components={{
- body: renderVirtualList
+ body: renderVirtualList,
}}
/>
);
};
const wrapper = mount();
- expect(wrapper.find('col').at(noChildColLen + ChildColLen * 2 - 1).props().style.width + wrapper.find('col').last().props().style.width).toEqual(width);
- })
+ expect(
+ wrapper
+ .find('col')
+ .at(noChildColLen + ChildColLen * 2 - 1)
+ .props().style.width + wrapper.find('col').last().props().style.width,
+ ).toEqual(width);
+ });
});