Skip to content

Commit

Permalink
test: add case
Browse files Browse the repository at this point in the history
  • Loading branch information
linxianxi committed Apr 28, 2024
1 parent 07afed4 commit a0c6cac
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion tests/Virtual.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('Table.Virtual', () => {
scrollLeft: {
get: () => {
scrollLeftCalled = true;
return 100;
return 0;
},
set: () => {},
},
Expand Down Expand Up @@ -443,4 +443,51 @@ describe('Table.Virtual', () => {
fireEvent.scroll(container.querySelector('.rc-table-tbody-virtual-holder')!);
expect(onScroll).toHaveBeenCalled();
});

it('horizontal virtual', async () => {
const { container } = getTable({
virtual: { x: true },
columns: [
{
width: 100,
className: 'a',
},
{
width: 50,
className: 'b',
},
{
width: 100,
className: 'c',
},
{
width: 50,
className: 'd',
},
],
scroll: {
x: 300,
y: 10,
},
getContainerWidth: () => 200,
data: [{}],
});

resize(container.querySelector('.rc-table'));

await waitFakeTimer();

expect(container.querySelector('.rc-table-row').children.length).toBe(3);
expect(container.querySelector('.rc-table-row').children[0].classList).toContain('a');
expect(container.querySelector('.rc-table-row').children[1].classList).toContain('b');
expect(container.querySelector('.rc-table-row').children[2].classList).toContain('c');

fireEvent.wheel(container.querySelector('.rc-table-tbody-virtual-holder')!, {
deltaX: 100,
});
expect(container.querySelector('.rc-table-row').children.length).toBe(3);
expect(container.querySelector('.rc-table-row').children[0].classList).toContain('b');
expect(container.querySelector('.rc-table-row').children[1].classList).toContain('c');
expect(container.querySelector('.rc-table-row').children[2].classList).toContain('d');
});
});

0 comments on commit a0c6cac

Please sign in to comment.