Skip to content

Commit 39d47f4

Browse files
authored
Merge pull request #7005 from IgniteUI/hPopov/refactor-hGrid-selection-tests-90x
Refactor Hgrid Selection test suite (9.0.x)
2 parents bb1c0c0 + 5a8f77d commit 39d47f4

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.selection.spec.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,21 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
4949
rowIsland2 = fix.componentInstance.rowIsland2;
5050
}));
5151

52-
it('should allow only one cell to be selected in the whole hierarchical grid.', (async () => {
52+
it('should allow only one cell to be selected in the whole hierarchical grid.', fakeAsync(() => {
5353
hierarchicalGrid.height = '500px';
5454
hierarchicalGrid.reflow();
5555
fix.detectChanges();
5656

5757
let firstRow = hierarchicalGrid.getRowByIndex(0) as IgxHierarchicalRowComponent;
5858
firstRow.toggle();
5959
fix.detectChanges();
60+
tick(100);
6061
expect(firstRow.expanded).toBeTruthy();
6162

6263
let fCell = firstRow.cells.toArray()[0];
6364

6465
// select parent cell
6566
fCell.nativeElement.focus();
66-
await wait(100);
6767
fix.detectChanges();
6868

6969
expect(fCell.selected).toBeTruthy();
@@ -74,7 +74,6 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
7474

7575
// select child cell
7676
fChildCell.nativeElement.focus();
77-
await wait(100);
7877
fix.detectChanges();
7978

8079
expect(fChildCell.selected).toBeTruthy();
@@ -84,11 +83,11 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
8483
firstRow = hierarchicalGrid.getRowByIndex(0) as IgxHierarchicalRowComponent;
8584
fCell = firstRow.cells.toArray()[0];
8685
fCell.nativeElement.focus();
87-
await wait(100);
8886
fix.detectChanges();
8987
expect(fChildCell.selected).toBeFalsy();
9088
expect(fCell.selected).toBeTruthy();
9189
}));
90+
9291
});
9392

9493
describe('Row Selection', () => {
@@ -102,8 +101,8 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
102101

103102
it('should have checkboxes on each row', fakeAsync(() => {
104103
hierarchicalGrid.expandChildren = true;
105-
fix.detectChanges();
106104
tick(100);
105+
fix.detectChanges();
107106
rowIsland1.expandChildren = true;
108107
tick(100);
109108
fix.detectChanges();
@@ -144,7 +143,7 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
144143
const childGridLevel2 = childGridLevel1.hgridAPI.getChildGrids(false)[0];
145144

146145
hierarchicalGrid.selectAllRows();
147-
childGridLevel1.selectedRows(['00']);
146+
childGridLevel1.selectRows(['00']);
148147
fix.detectChanges();
149148

150149
// Change row selection for grids
@@ -493,7 +492,7 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
493492
expect(hierarchicalGrid.selectedRows()).toEqual(['1', '2', '3', '4']);
494493

495494
// Click on a row
496-
secondRow.nativeElement.dispatchEvent(new MouseEvent('click'));
495+
secondRow.onClick(UIInteractions.getMouseEvent('click'));
497496
fix.detectChanges();
498497

499498
GridSelectionFunctions.verifyRowSelected(secondRow);
@@ -503,7 +502,7 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
503502

504503
it('should retain selected row when filtering', () => {
505504
const firstRow = hierarchicalGrid.getRowByIndex(0);
506-
GridSelectionFunctions.clickRowCheckbox(firstRow);
505+
firstRow.onRowSelectorClick(UIInteractions.getMouseEvent('click'));
507506
fix.detectChanges();
508507

509508
hierarchicalGrid.filter('ID', '1', IgxStringFilteringOperand.instance().condition('doesNotContain'), true);
@@ -513,7 +512,7 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
513512
GridSelectionFunctions.verifyHeaderRowCheckboxState(fix, false, true);
514513
});
515514

516-
it('should child grid selection should not be changed when filter parent', () => {
515+
it('child grid selection should not be changed when filter parent', () => {
517516
rowIsland1.rowSelection = GridSelectionMode.multiple;
518517
fix.detectChanges();
519518

@@ -561,13 +560,14 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
561560
GridSelectionFunctions.verifyRowsArraySelected(childGrid.dataRowList.toArray());
562561
});
563562

564-
it('should not be able to select deleted row', () => {
563+
it('should not be able to select deleted row', fakeAsync(() => {
565564
// Expand first row
566565
const firstRow = hierarchicalGrid.getRowByIndex(0) as IgxHierarchicalRowComponent;
567566
firstRow.toggle();
568567
fix.detectChanges();
569568

570-
UIInteractions.simulateClickEvent(firstRow.nativeElement);
569+
firstRow.onClick(UIInteractions.getMouseEvent('click'));
570+
tick();
571571
fix.detectChanges();
572572

573573
GridSelectionFunctions.verifyRowSelected(firstRow);
@@ -582,15 +582,16 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
582582
expect(hierarchicalGrid.selectedRows()).toEqual([]);
583583

584584
// Click on deleted row
585-
UIInteractions.simulateClickEvent(firstRow.nativeElement);
585+
firstRow.onClick(UIInteractions.getMouseEvent('click'));
586+
tick();
586587
fix.detectChanges();
587588

588589
GridSelectionFunctions.verifyRowSelected(firstRow, false);
589590
GridSelectionFunctions.verifyHeaderRowCheckboxState(fix);
590591
expect(hierarchicalGrid.selectedRows()).toEqual([]);
591592

592593
// Click on checkbox for deleted row
593-
GridSelectionFunctions.clickRowCheckbox(firstRow);
594+
firstRow.onRowSelectorClick(UIInteractions.getMouseEvent('click'));
594595
fix.detectChanges();
595596

596597
GridSelectionFunctions.verifyRowSelected(firstRow, false);
@@ -610,14 +611,15 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
610611
expect(childGrid.selectedRows()).toEqual([]);
611612

612613
const childGridFirstRow = childGrid.getRowByIndex(0);
613-
UIInteractions.simulateClickEvent(childGridFirstRow.nativeElement, false, true);
614+
childGridFirstRow.onClick(UIInteractions.getMouseEvent('click', false, false, true));
615+
tick();
614616
fix.detectChanges();
615617

616618
GridSelectionFunctions.verifyRowSelected(firstRow, false);
617619
GridSelectionFunctions.verifyHeaderRowCheckboxState(fix, true);
618620
expect(hierarchicalGrid.selectedRows()).toEqual(['1', '2', '3', '4']);
619621
expect(childGrid.selectedRows()).toEqual(['00']);
620-
});
622+
}));
621623

622624
it('should be able to select added row', () => {
623625
// Set multiple selection to first row island
@@ -684,7 +686,7 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
684686
}));
685687

686688
it('should deselect deleted row', () => {
687-
GridSelectionFunctions.clickHeaderRowCheckbox(hierarchicalGrid);
689+
hierarchicalGrid.onHeaderSelectorClick(UIInteractions.getMouseEvent('click'));
688690
fix.detectChanges();
689691

690692
GridSelectionFunctions.verifyHeaderRowCheckboxState(hierarchicalGrid, true);

0 commit comments

Comments
 (0)