Skip to content

Commit 54f6405

Browse files
committed
chore(*): address requested changes
1 parent 5dcc73c commit 54f6405

File tree

1 file changed

+42
-40
lines changed

1 file changed

+42
-40
lines changed

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

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
4747
hierarchicalGrid.reflow();
4848
fix.detectChanges();
4949

50-
let firstRow = hierarchicalGrid.dataRowList.toArray()[0] as IgxHierarchicalRowComponent;
51-
firstRow.nativeElement.children[0].click();
50+
let firstRow = hierarchicalGrid.getRowByIndex(0) as IgxHierarchicalRowComponent;
51+
firstRow.toggle();
5252
fix.detectChanges();
5353
expect(firstRow.expanded).toBeTruthy();
5454

@@ -62,7 +62,7 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
6262
expect(fCell.selected).toBeTruthy();
6363

6464
const childGrid = hierarchicalGrid.hgridAPI.getChildGrids(false)[0];
65-
const firstChildRow = childGrid.dataRowList.toArray()[0];
65+
const firstChildRow = childGrid.getRowByIndex(0);
6666
const fChildCell = firstChildRow.cells.toArray()[0];
6767

6868
// select child cell
@@ -74,7 +74,7 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
7474
expect(fCell.selected).toBeFalsy();
7575

7676
// select parent cell
77-
firstRow = hierarchicalGrid.dataRowList.toArray()[0] as IgxHierarchicalRowComponent;
77+
firstRow = hierarchicalGrid.getRowByIndex(0) as IgxHierarchicalRowComponent;
7878
fCell = firstRow.cells.toArray()[0];
7979
fCell.nativeElement.focus();
8080
await wait(100);
@@ -217,7 +217,7 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
217217
const mockEvent = new MouseEvent('click');
218218

219219
// Click on a row in child grid
220-
let row = childGrid.dataRowList.toArray()[0];
220+
let row = childGrid.getRowByIndex(0);
221221
row.nativeElement.dispatchEvent(mockEvent);
222222
fix.detectChanges();
223223

@@ -235,7 +235,7 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
235235
});
236236

237237
// Click on checkbox on second row
238-
HelperUtils.getRowCheckboxDiv(childGrid.dataRowList.toArray()[1].nativeElement).dispatchEvent(mockEvent);
238+
HelperUtils.getRowCheckboxDiv(childGrid.getRowByIndex(1).nativeElement).dispatchEvent(mockEvent);
239239
fix.detectChanges();
240240

241241
expect(secondChildSpy).toHaveBeenCalledTimes(0);
@@ -252,7 +252,7 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
252252
});
253253

254254
// Click on a row in parent grid
255-
row = hierarchicalGrid.dataRowList.toArray()[1];
255+
row = hierarchicalGrid.getRowByIndex(2);
256256
row.nativeElement.dispatchEvent(mockEvent);
257257
fix.detectChanges();
258258

@@ -286,9 +286,9 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
286286
});
287287

288288
it('should able to select multiple rows with Shift and click', () => {
289-
// Expand first row
290-
const firstRow = hierarchicalGrid.dataRowList.toArray()[0];
291-
firstRow.nativeElement.children[0].click();
289+
// Click first row expand button
290+
const firstRow = hierarchicalGrid.getRowByIndex(0) as IgxHierarchicalRowComponent;
291+
firstRow.toggle();
292292
fix.detectChanges();
293293

294294
HelperUtils.verifyRowSelected(firstRow, false);
@@ -299,12 +299,12 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
299299
HelperUtils.verifyRowSelected(firstRow);
300300
expect(hierarchicalGrid.selectedRows()).toEqual(['0']);
301301

302-
const fourthRow = hierarchicalGrid.dataRowList.toArray()[3];
302+
const fourthRow = hierarchicalGrid.getRowByIndex(4);
303303
UIInteractions.simulateClickEvent(fourthRow.nativeElement, true);
304304
fix.detectChanges();
305305

306306
HelperUtils.verifyRowsArraySelected(
307-
[firstRow, hierarchicalGrid.dataRowList.toArray()[1], hierarchicalGrid.dataRowList.toArray()[2], fourthRow]);
307+
[firstRow, hierarchicalGrid.getRowByIndex(2), hierarchicalGrid.getRowByIndex(3), fourthRow]);
308308
expect(hierarchicalGrid.selectedRows()).toEqual(['0', '1', '2', '3']);
309309

310310
// Verify no rows are selected in the child grid
@@ -317,8 +317,8 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
317317

318318
it('should able to select multiple rows with Ctrl and click', () => {
319319
// Expand first row
320-
const firstRow = hierarchicalGrid.dataRowList.toArray()[0];
321-
firstRow.nativeElement.children[0].click();
320+
const firstRow = hierarchicalGrid.getRowByIndex(0) as IgxHierarchicalRowComponent;
321+
firstRow.toggle();
322322
fix.detectChanges();
323323

324324
HelperUtils.verifyRowSelected(firstRow, false);
@@ -329,7 +329,7 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
329329
HelperUtils.verifyRowSelected(firstRow);
330330
expect(hierarchicalGrid.selectedRows()).toEqual(['0']);
331331

332-
const fourthRow = hierarchicalGrid.dataRowList.toArray()[3];
332+
const fourthRow = hierarchicalGrid.getRowByIndex(4);
333333
UIInteractions.simulateClickEvent(fourthRow.nativeElement, false, true);
334334
fix.detectChanges();
335335

@@ -340,7 +340,7 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
340340
const childGrid = hierarchicalGrid.hgridAPI.getChildGrids(false)[0];
341341
expect(childGrid.selectedRows()).toEqual([]);
342342

343-
const childGridFirstRow = childGrid.dataRowList.toArray()[2];
343+
const childGridFirstRow = childGrid.getRowByIndex(2);
344344
UIInteractions.simulateClickEvent(childGridFirstRow.nativeElement, false, true);
345345
fix.detectChanges();
346346

@@ -352,15 +352,16 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
352352

353353
it('should able to select only one row when rowSelection is single', () => {
354354
// Expand first row
355-
hierarchicalGrid.dataRowList.toArray()[0].nativeElement.children[0].click();
355+
const row = hierarchicalGrid.getRowByIndex(0) as IgxHierarchicalRowComponent;
356+
row.toggle();
356357
fix.detectChanges();
357358

358359
// Click on a row in the child grid
359360
const childGrid = hierarchicalGrid.hgridAPI.getChildGrids(false)[0];
360361
expect(childGrid.selectedRows()).toEqual([]);
361362

362-
const firstRow = childGrid.dataRowList.toArray()[0];
363-
const secondRow = childGrid.dataRowList.toArray()[2];
363+
const firstRow = childGrid.getRowByIndex(0);
364+
const secondRow = childGrid.getRowByIndex(2);
364365

365366
UIInteractions.simulateClickEvent(firstRow.nativeElement);
366367
fix.detectChanges();
@@ -399,13 +400,13 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
399400
fix.detectChanges();
400401

401402
// Expand first row
402-
const firstRow = hierarchicalGrid.dataRowList.toArray()[0];
403-
firstRow.nativeElement.children[0].click();
403+
let row = hierarchicalGrid.getRowByIndex(0) as IgxHierarchicalRowComponent;
404+
row.toggle();
404405
fix.detectChanges();
405406

406407
// Expand second row
407-
const secondRow = hierarchicalGrid.dataRowList.toArray()[1];
408-
secondRow.nativeElement.children[0].click();
408+
row = hierarchicalGrid.getRowByIndex(2) as IgxHierarchicalRowComponent;
409+
row.toggle();
409410
fix.detectChanges();
410411

411412
// Select all rows in parent
@@ -508,12 +509,12 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
508509
fix.detectChanges();
509510

510511
// expand first row
511-
const firstRow = hierarchicalGrid.dataRowList.toArray()[0];
512-
firstRow.nativeElement.children[0].click();
512+
let row = hierarchicalGrid.getRowByIndex(0) as IgxHierarchicalRowComponent;
513+
row.toggle();
513514
fix.detectChanges();
514515

515516
// select second row
516-
const secondRow = hierarchicalGrid.dataRowList.toArray()[1];
517+
const secondRow = hierarchicalGrid.getRowByIndex(2);
517518
HelperUtils.clickRowCheckbox(secondRow);
518519
fix.detectChanges();
519520

@@ -533,7 +534,8 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
533534
HelperUtils.verifyHeaderRowCheckboxState(hierarchicalGrid, true);
534535

535536
// Expand filtered row
536-
hierarchicalGrid.dataRowList.toArray()[0].nativeElement.children[0].click();
537+
row = hierarchicalGrid.getRowByIndex(0) as IgxHierarchicalRowComponent;
538+
row.toggle();
537539
fix.detectChanges();
538540

539541
childGrid = hierarchicalGrid.hgridAPI.getChildGrids(false)[1];
@@ -552,8 +554,8 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
552554

553555
it('should not be able to select deleted row', () => {
554556
// Expand first row
555-
const firstRow = hierarchicalGrid.dataRowList.toArray()[0];
556-
firstRow.nativeElement.children[0].click();
557+
const firstRow = hierarchicalGrid.getRowByIndex(0) as IgxHierarchicalRowComponent;
558+
firstRow.toggle();
557559
fix.detectChanges();
558560

559561
UIInteractions.simulateClickEvent(firstRow.nativeElement);
@@ -598,7 +600,7 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
598600
const childGrid = hierarchicalGrid.hgridAPI.getChildGrids(false)[0];
599601
expect(childGrid.selectedRows()).toEqual([]);
600602

601-
const childGridFirstRow = childGrid.dataRowList.toArray()[0];
603+
const childGridFirstRow = childGrid.getRowByIndex(0);
602604
UIInteractions.simulateClickEvent(childGridFirstRow.nativeElement, false, true);
603605
fix.detectChanges();
604606

@@ -614,8 +616,8 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
614616
fix.detectChanges();
615617

616618
// Expand first row
617-
const firstRow = hierarchicalGrid.dataRowList.toArray()[0];
618-
firstRow.nativeElement.children[0].click();
619+
const firstRow = hierarchicalGrid.getRowByIndex(0) as IgxHierarchicalRowComponent;
620+
firstRow.toggle();
619621
fix.detectChanges();
620622

621623
HelperUtils.clickHeaderRowCheckbox(hierarchicalGrid);
@@ -629,7 +631,7 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
629631

630632
HelperUtils.verifyHeaderRowCheckboxState(hierarchicalGrid, false, true);
631633
expect(hierarchicalGrid.selectedRows()).toEqual(['0', '1', '2', '3', '4']);
632-
let lastRow = hierarchicalGrid.dataRowList.toArray()[5];
634+
let lastRow = hierarchicalGrid.getRowByIndex(6);
633635
HelperUtils.verifyRowSelected(lastRow, false);
634636

635637
HelperUtils.clickRowCheckbox(lastRow);
@@ -649,7 +651,7 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
649651

650652
HelperUtils.verifyHeaderRowCheckboxState(childGrid, true);
651653
expect(childGrid.selectedRows()).toEqual(['00', '01', '02', '03']);
652-
lastRow = childGrid.dataRowList.toArray()[3];
654+
lastRow = childGrid.getRowByIndex(3);
653655
HelperUtils.verifyRowSelected(lastRow);
654656
});
655657
});
@@ -677,7 +679,7 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
677679
expect(hierarchicalGrid.selectedRows()).toEqual(['0', '2', '3', '4']);
678680
expect(hierarchicalGrid.dataRowList.length).toEqual(4);
679681

680-
const firstRow = hierarchicalGrid.dataRowList.toArray()[0];
682+
const firstRow = hierarchicalGrid.getRowByIndex(0);
681683
HelperUtils.clickRowCheckbox(firstRow);
682684
fix.detectChanges();
683685

@@ -693,8 +695,9 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
693695
});
694696

695697
it('should be able to select added row', () => {
696-
const firstRow = hierarchicalGrid.dataRowList.toArray()[0];
697-
firstRow.nativeElement.children[0].click();
698+
// Expand first row
699+
const firstRow = hierarchicalGrid.getRowByIndex(0) as IgxHierarchicalRowComponent;
700+
firstRow.toggle();
698701
fix.detectChanges();
699702

700703
hierarchicalGrid.addRow({ ID: '5', ChildLevels: 3, ProductName: 'New Product' });
@@ -706,7 +709,7 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
706709
hierarchicalGrid.selectAllRows();
707710
fix.detectChanges();
708711

709-
let addedRow = hierarchicalGrid.dataRowList.toArray()[5];
712+
let addedRow = hierarchicalGrid.getRowByIndex(5);
710713
HelperUtils.verifyHeaderRowCheckboxState(hierarchicalGrid, true);
711714
HelperUtils.verifyRowSelected(addedRow);
712715

@@ -719,7 +722,7 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
719722
childGrid.addRow({ ID: '03', ChildLevels: 3, ProductName: 'New Product' });
720723
fix.detectChanges();
721724

722-
addedRow = childGrid.dataRowList.toArray()[3];
725+
addedRow = childGrid.getRowByIndex(3);
723726
HelperUtils.verifyRowSelected(addedRow, false);
724727
HelperUtils.verifyHeaderRowCheckboxState(childGrid, false, true);
725728
HelperUtils.verifyHeaderRowCheckboxState(hierarchicalGrid, true);
@@ -730,5 +733,4 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
730733
HelperUtils.verifyHeaderRowCheckboxState(childGrid, true);
731734
});
732735
});
733-
734736
});

0 commit comments

Comments
 (0)