Skip to content

Commit a9a942d

Browse files
committed
test(igxTreeGrid): Adds more tests concerning the rp #6640
1 parent 879652a commit a9a942d

File tree

1 file changed

+97
-12
lines changed

1 file changed

+97
-12
lines changed

projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid-integration.spec.ts

+97-12
Original file line numberDiff line numberDiff line change
@@ -1378,12 +1378,14 @@ describe('IgxTreeGrid - Integration #tGrid', () => {
13781378
});
13791379

13801380
describe('Row Pinning', () => {
1381-
it('should pin/unpin a row', () => {
1381+
beforeEach(fakeAsync(/** height/width setter rAF */() => {
13821382
fix = TestBed.createComponent(IgxTreeGridRowPinningComponent);
13831383
fix.detectChanges();
13841384

13851385
treeGrid = fix.componentInstance.treeGrid as IgxTreeGridComponent;
1386+
}));
13861387

1388+
it('should pin/unpin a row', () => {
13871389
treeGrid.pinRow(711);
13881390
fix.detectChanges();
13891391

@@ -1405,10 +1407,6 @@ describe('IgxTreeGrid - Integration #tGrid', () => {
14051407
});
14061408

14071409
it('should pin/unpin a row at the bottom', () => {
1408-
fix = TestBed.createComponent(IgxTreeGridRowPinningComponent);
1409-
fix.detectChanges();
1410-
1411-
treeGrid = fix.componentInstance.treeGrid as IgxTreeGridComponent;
14121410
/* Pin rows to bottom */
14131411
treeGrid.pinning.rows = 1;
14141412

@@ -1420,11 +1418,6 @@ describe('IgxTreeGrid - Integration #tGrid', () => {
14201418
});
14211419

14221420
it('should calculate row indices correctly after row pinning', async () => {
1423-
fix = TestBed.createComponent(IgxTreeGridRowPinningComponent);
1424-
fix.detectChanges();
1425-
1426-
treeGrid = fix.componentInstance.treeGrid as IgxTreeGridComponent;
1427-
14281421
const firstRow = treeGrid.getRowByIndex(0);
14291422
const secondRow = treeGrid.getRowByIndex(1);
14301423

@@ -1445,7 +1438,99 @@ describe('IgxTreeGrid - Integration #tGrid', () => {
14451438
expect(treeGrid.getRowByIndex(0).rowID).toBe(firstRow.rowID);
14461439
expect(treeGrid.getRowByIndex(1).rowID).toBe(secondRow.rowID);
14471440
});
1448-
it('should disable pinned row instance in the body', () => {});
1449-
it('should add pinned badge in the pinned row instance in the body', () => {});
1441+
1442+
it('should disable pinned row instance in the body', () => {
1443+
const rowToPin = treeGrid.getRowByIndex(0);
1444+
const primaryKey = treeGrid.primaryKey;
1445+
1446+
treeGrid.pinRow(rowToPin.rowData[primaryKey]);
1447+
fix.detectChanges();
1448+
1449+
expect(treeGrid.getRowByIndex(0).disabled).toBe(false);
1450+
expect(treeGrid.getRowByIndex(1).disabled).toBe(true);
1451+
1452+
treeGrid.unpinRow(rowToPin.rowData[primaryKey]);
1453+
fix.detectChanges();
1454+
1455+
expect(treeGrid.getRowByIndex(0).disabled).toBe(false);
1456+
expect(treeGrid.getRowByIndex(1).disabled).toBe(false);
1457+
1458+
});
1459+
1460+
it('should add pinned badge in the pinned row instance in the body', () => {
1461+
const rowToPin = treeGrid.getRowByIndex(0);
1462+
const primaryKey = treeGrid.primaryKey;
1463+
1464+
treeGrid.pinRow(rowToPin.rowData[primaryKey]);
1465+
fix.detectChanges();
1466+
1467+
const firstColumnField = treeGrid.columns[0].field;
1468+
const pinnedChipPosition = treeGrid.getCellByColumn(1, firstColumnField);
1469+
const pinnedRowCell = treeGrid.getCellByColumn(0, firstColumnField);
1470+
const wrongChipPosition = treeGrid.getCellByColumn(2, firstColumnField);
1471+
1472+
expect(pinnedChipPosition.nativeElement.getElementsByClassName('igx-grid__td--pinned-chip').length).toBe(1);
1473+
expect(pinnedRowCell.nativeElement.getElementsByClassName('igx-grid__td--pinned-chip').length).toBe(0);
1474+
expect(wrongChipPosition.nativeElement.getElementsByClassName('igx-grid__td--pinned-chip').length).toBe(0);
1475+
});
1476+
1477+
it('pinned chip should always be in the first column', () => {
1478+
const rowToPin = treeGrid.getRowByIndex(0);
1479+
const primaryKey = treeGrid.primaryKey;
1480+
1481+
treeGrid.pinRow(rowToPin.rowData[primaryKey]);
1482+
fix.detectChanges();
1483+
1484+
const thirdColumnField = treeGrid.columns[2].field;
1485+
1486+
treeGrid.moveColumn(treeGrid.columns[2], treeGrid.columns[0]);
1487+
fix.detectChanges();
1488+
1489+
const pinnedChipExpectedPosition = treeGrid.getCellByColumn(1, thirdColumnField);
1490+
expect(pinnedChipExpectedPosition.nativeElement.getElementsByClassName('igx-grid__td--pinned-chip').length).toBe(1);
1491+
});
1492+
1493+
it('should expand/collapse a pinned row with children', () => {
1494+
let rows = TreeGridFunctions.getAllRows(fix);
1495+
expect(rows.length).toBe(10);
1496+
const rowToPin = treeGrid.getRowByIndex(0);
1497+
1498+
rowToPin.pin();
1499+
fix.detectChanges();
1500+
1501+
// collapse pinned row
1502+
treeGrid.toggleRow(rowToPin.rowID);
1503+
fix.detectChanges();
1504+
1505+
rows = TreeGridFunctions.getAllRows(fix);
1506+
expect(rows.length).toBe(5);
1507+
1508+
// expand the pinned row
1509+
treeGrid.toggleRow(rowToPin.rowID);
1510+
fix.detectChanges();
1511+
1512+
rows = TreeGridFunctions.getAllRows(fix);
1513+
expect(rows.length).toBe(11);
1514+
});
1515+
1516+
it('should search in both pinned and unpinned rows', () => {
1517+
let searchResultsCount = treeGrid.findNext('John');
1518+
expect(searchResultsCount).toBe(1);
1519+
1520+
const rowToPin = treeGrid.getRowByIndex(0);
1521+
rowToPin.pin();
1522+
fix.detectChanges();
1523+
1524+
searchResultsCount = treeGrid.findNext('John');
1525+
expect(searchResultsCount).toBe(2);
1526+
});
1527+
1528+
it('should apply filtering to both pinned and unpinned rows', () => {});
1529+
1530+
it('should apply sorting to both pinned and unpinned rows', () => {});
1531+
1532+
it('should not take into account pinned rows when changing items per page', () => {});
1533+
1534+
it('should make a correct selection', () => {});
14501535
});
14511536
});

0 commit comments

Comments
 (0)