mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-14 08:09:13 +08:00
87882e1db6
* fix(style): Virtual table style lead on none virtual table render used as a nested table. * fix(test): Update test for virtual table with fix nested table inside. --------- Co-authored-by: ykryshtal <ykryshtal@magnite.com> Co-authored-by: Eugene <Jeka1.1@mail.ru>
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
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(
|
|
'.ant-table-wrapper .ant-table-tbody-virtual .ant-table-row:not(tr)',
|
|
),
|
|
).toHaveLength(1);
|
|
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.y` in virtual table must be number.');
|
|
errSpy.mockRestore();
|
|
});
|
|
});
|