Skip to content

Commit 6d32b7b

Browse files
committed
test: add tests for the height resetting fix
1 parent 2fff077 commit 6d32b7b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

__tests__/VariableSizeTree.spec.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,16 @@ describe('VariableSizeTree', () => {
226226
});
227227

228228
describe('recomputeTree', () => {
229+
let resetAfterIndexSpy: jest.SpyInstance;
230+
231+
beforeEach(() => {
232+
const listInstance = component
233+
.find(VariableSizeList)
234+
.instance() as VariableSizeList;
235+
236+
resetAfterIndexSpy = jest.spyOn(listInstance, 'resetAfterIndex');
237+
});
238+
229239
it('updates tree order', async () => {
230240
tree = {
231241
children: [
@@ -284,6 +294,8 @@ describe('VariableSizeTree', () => {
284294
treeData: undefined,
285295
},
286296
);
297+
298+
expect(resetAfterIndexSpy).toHaveBeenCalledWith(0, true);
287299
});
288300

289301
it('updates tree nodes metadata', async () => {
@@ -344,6 +356,8 @@ describe('VariableSizeTree', () => {
344356
treeData: undefined,
345357
},
346358
);
359+
360+
expect(resetAfterIndexSpy).toHaveBeenCalledWith(0, true);
347361
});
348362

349363
it('resets current openness to default', async () => {
@@ -408,6 +422,8 @@ describe('VariableSizeTree', () => {
408422
treeData: undefined,
409423
},
410424
);
425+
426+
expect(resetAfterIndexSpy).toHaveBeenCalledWith(0, true);
411427
});
412428

413429
it('resets current openness to the new default provided by the node refreshing', async () => {
@@ -465,6 +481,8 @@ describe('VariableSizeTree', () => {
465481
treeData: undefined,
466482
},
467483
);
484+
485+
expect(resetAfterIndexSpy).toHaveBeenCalledWith(0, true);
468486
});
469487

470488
it('provides a toggle function that changes openness state of the specific node', async () => {
@@ -482,6 +500,8 @@ describe('VariableSizeTree', () => {
482500
expect(treeWalkerSpy).toHaveBeenCalledWith(false);
483501
expect(foo1.height).toBe(defaultHeight);
484502
expect(foo1.isOpen).toBeFalsy();
503+
504+
expect(resetAfterIndexSpy).toHaveBeenCalledWith(0, true);
485505
});
486506

487507
it('resets current height to default', async () => {
@@ -548,6 +568,8 @@ describe('VariableSizeTree', () => {
548568
treeData: undefined,
549569
},
550570
);
571+
572+
expect(resetAfterIndexSpy).toHaveBeenCalledWith(0, true);
551573
});
552574

553575
it('resets current height to the new default provided by the node refreshing', async () => {
@@ -605,6 +627,8 @@ describe('VariableSizeTree', () => {
605627
treeData: undefined,
606628
},
607629
);
630+
631+
expect(resetAfterIndexSpy).toHaveBeenCalledWith(0, true);
608632
});
609633

610634
it('opens and closes nodes as specified in opennessState', async () => {
@@ -646,6 +670,7 @@ describe('VariableSizeTree', () => {
646670
expect(foo1!.isOpen).toBeTruthy();
647671
expect(foo2!.isOpen).toBeTruthy();
648672
expect(foo3!.isOpen).not.toBeTruthy();
673+
expect(resetAfterIndexSpy).toHaveBeenCalledWith(0, true);
649674
});
650675

651676
it('opennessState is overridden by useDefaultOpenness', async () => {

0 commit comments

Comments
 (0)