Skip to content

Commit

Permalink
test: add fixed case
Browse files Browse the repository at this point in the history
  • Loading branch information
linxianxi committed Apr 29, 2024
1 parent df413af commit 0c4cd8b
Showing 1 changed file with 67 additions and 8 deletions.
75 changes: 67 additions & 8 deletions tests/Virtual.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -477,17 +477,76 @@ describe('Table.Virtual', () => {

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');
let rowNodeChildren = container.querySelector('.rc-table-row').children;

expect(rowNodeChildren.length).toBe(3);
expect(rowNodeChildren[0].classList).toContain('a');
expect(rowNodeChildren[1].classList).toContain('b');
expect(rowNodeChildren[2].classList).toContain('c');

fireEvent.wheel(container.querySelector('.rc-table-tbody-virtual-holder')!, {
deltaX: 100,
});

rowNodeChildren = container.querySelector('.rc-table-row').children;

expect(rowNodeChildren.length).toBe(3);
expect(rowNodeChildren[0].classList).toContain('b');
expect(rowNodeChildren[1].classList).toContain('c');
expect(rowNodeChildren[2].classList).toContain('d');
});

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

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

await waitFakeTimer();

let rowNodeChildren = container.querySelector('.rc-table-row').children;

expect(rowNodeChildren.length).toBe(3);
expect(rowNodeChildren[0].classList).toContain('a');
expect(rowNodeChildren[1].classList).toContain('b');
expect(rowNodeChildren[2].classList).toContain('d');

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');

rowNodeChildren = container.querySelector('.rc-table-row').children;

expect(rowNodeChildren.length).toBe(3);
expect(rowNodeChildren[0].classList).toContain('a');
expect(rowNodeChildren[1].classList).toContain('c');
expect(rowNodeChildren[2].classList).toContain('d');
});
});

0 comments on commit 0c4cd8b

Please sign in to comment.