@@ -1378,12 +1378,14 @@ describe('IgxTreeGrid - Integration #tGrid', () => {
1378
1378
} ) ;
1379
1379
1380
1380
describe ( 'Row Pinning' , ( ) => {
1381
- it ( 'should pin/unpin a row' , ( ) => {
1381
+ beforeEach ( fakeAsync ( /** height/width setter rAF */ ( ) => {
1382
1382
fix = TestBed . createComponent ( IgxTreeGridRowPinningComponent ) ;
1383
1383
fix . detectChanges ( ) ;
1384
1384
1385
1385
treeGrid = fix . componentInstance . treeGrid as IgxTreeGridComponent ;
1386
+ } ) ) ;
1386
1387
1388
+ it ( 'should pin/unpin a row' , ( ) => {
1387
1389
treeGrid . pinRow ( 711 ) ;
1388
1390
fix . detectChanges ( ) ;
1389
1391
@@ -1405,10 +1407,6 @@ describe('IgxTreeGrid - Integration #tGrid', () => {
1405
1407
} ) ;
1406
1408
1407
1409
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 ;
1412
1410
/* Pin rows to bottom */
1413
1411
treeGrid . pinning . rows = 1 ;
1414
1412
@@ -1420,11 +1418,6 @@ describe('IgxTreeGrid - Integration #tGrid', () => {
1420
1418
} ) ;
1421
1419
1422
1420
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
-
1428
1421
const firstRow = treeGrid . getRowByIndex ( 0 ) ;
1429
1422
const secondRow = treeGrid . getRowByIndex ( 1 ) ;
1430
1423
@@ -1445,7 +1438,99 @@ describe('IgxTreeGrid - Integration #tGrid', () => {
1445
1438
expect ( treeGrid . getRowByIndex ( 0 ) . rowID ) . toBe ( firstRow . rowID ) ;
1446
1439
expect ( treeGrid . getRowByIndex ( 1 ) . rowID ) . toBe ( secondRow . rowID ) ;
1447
1440
} ) ;
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' , ( ) => { } ) ;
1450
1535
} ) ;
1451
1536
} ) ;
0 commit comments