Skip to content

Commit 0c4cd8b

Browse files
committed
test: add fixed case
1 parent df413af commit 0c4cd8b

File tree

1 file changed

+67
-8
lines changed

1 file changed

+67
-8
lines changed

tests/Virtual.spec.tsx

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -477,17 +477,76 @@ describe('Table.Virtual', () => {
477477

478478
await waitFakeTimer();
479479

480-
expect(container.querySelector('.rc-table-row').children.length).toBe(3);
481-
expect(container.querySelector('.rc-table-row').children[0].classList).toContain('a');
482-
expect(container.querySelector('.rc-table-row').children[1].classList).toContain('b');
483-
expect(container.querySelector('.rc-table-row').children[2].classList).toContain('c');
480+
let rowNodeChildren = container.querySelector('.rc-table-row').children;
481+
482+
expect(rowNodeChildren.length).toBe(3);
483+
expect(rowNodeChildren[0].classList).toContain('a');
484+
expect(rowNodeChildren[1].classList).toContain('b');
485+
expect(rowNodeChildren[2].classList).toContain('c');
486+
487+
fireEvent.wheel(container.querySelector('.rc-table-tbody-virtual-holder')!, {
488+
deltaX: 100,
489+
});
490+
491+
rowNodeChildren = container.querySelector('.rc-table-row').children;
492+
493+
expect(rowNodeChildren.length).toBe(3);
494+
expect(rowNodeChildren[0].classList).toContain('b');
495+
expect(rowNodeChildren[1].classList).toContain('c');
496+
expect(rowNodeChildren[2].classList).toContain('d');
497+
});
498+
499+
it('fixed column in horizontal virtual', async () => {
500+
const { container } = getTable({
501+
virtual: { x: true },
502+
columns: [
503+
{
504+
width: 100,
505+
className: 'a',
506+
fixed: 'left',
507+
},
508+
{
509+
width: 100,
510+
className: 'b',
511+
},
512+
{
513+
width: 100,
514+
className: 'c',
515+
},
516+
{
517+
width: 100,
518+
className: 'd',
519+
fixed: 'right',
520+
},
521+
],
522+
scroll: {
523+
x: 300,
524+
y: 10,
525+
},
526+
getContainerWidth: () => 200,
527+
data: [{}],
528+
});
529+
530+
resize(container.querySelector('.rc-table'));
531+
532+
await waitFakeTimer();
533+
534+
let rowNodeChildren = container.querySelector('.rc-table-row').children;
535+
536+
expect(rowNodeChildren.length).toBe(3);
537+
expect(rowNodeChildren[0].classList).toContain('a');
538+
expect(rowNodeChildren[1].classList).toContain('b');
539+
expect(rowNodeChildren[2].classList).toContain('d');
484540

485541
fireEvent.wheel(container.querySelector('.rc-table-tbody-virtual-holder')!, {
486542
deltaX: 100,
487543
});
488-
expect(container.querySelector('.rc-table-row').children.length).toBe(3);
489-
expect(container.querySelector('.rc-table-row').children[0].classList).toContain('b');
490-
expect(container.querySelector('.rc-table-row').children[1].classList).toContain('c');
491-
expect(container.querySelector('.rc-table-row').children[2].classList).toContain('d');
544+
545+
rowNodeChildren = container.querySelector('.rc-table-row').children;
546+
547+
expect(rowNodeChildren.length).toBe(3);
548+
expect(rowNodeChildren[0].classList).toContain('a');
549+
expect(rowNodeChildren[1].classList).toContain('c');
550+
expect(rowNodeChildren[2].classList).toContain('d');
492551
});
493552
});

0 commit comments

Comments
 (0)