ant-design/components/table/__tests__/Table.virtual.test.tsx
二货爱吃白萝卜 6f2bddd5a1
feat: Table support virtual (#44349)
* chore: update demo

* chore: adjust fixed style

* chore: opt scroll height

* chore: clean up

* chore: update demo

* chore: bump rc-virtual-list

* chore: update deps

* chore: bump rc-table

* fix: clean up

* chore: fix demo

* test: add test case
2023-08-28 17:36:23 +08:00

40 lines
988 B
TypeScript

import React from 'react';
import Table from '..';
import { render } from '../../../tests/utils';
describe('Table.Virtual', () => {
it('should work', () => {
const { container } = render(
<Table
virtual
scroll={{ x: 100, y: 100 }}
columns={[
{
dataIndex: 'key',
},
]}
dataSource={[
{
key: 'bamboo',
},
]}
/>,
);
expect(container.querySelectorAll('.rc-virtual-list-holder .ant-table-cell')).toHaveLength(1);
expect(container.querySelector('.rc-virtual-list-holder .ant-table-cell')?.textContent).toEqual(
'bamboo',
);
});
// warning from `rc-table`
it('warning if no scroll', () => {
const errSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
render(<Table virtual />);
expect(errSpy).toHaveBeenCalledWith('Warning: `scroll.x` in virtual table must be number.');
errSpy.mockRestore();
});
});