@@ -12,6 +12,7 @@ import { PivotDimensionType } from './pivot-grid.interface';
12
12
import { IgxPivotHeaderRowComponent } from './pivot-header-row.component' ;
13
13
import { IgxPivotDateDimension , IgxPivotGridModule } from './public_api' ;
14
14
import { IgxPivotRowDimensionHeaderComponent } from './pivot-row-dimension-header.component' ;
15
+ import { IgxPivotDateAggregate } from './pivot-grid-aggregate' ;
15
16
const CSS_CLASS_DROP_DOWN_BASE = 'igx-drop-down' ;
16
17
const CSS_CLASS_LIST = 'igx-drop-down__list' ;
17
18
const CSS_CLASS_ITEM = 'igx-drop-down__item' ;
@@ -1241,7 +1242,7 @@ describe('IgxPivotGrid Resizing #pivotGrid', () => {
1241
1242
} ) ) ;
1242
1243
} ) ;
1243
1244
1244
- fdescribe ( 'IgxPivotGrid APIs #pivotGrid' , ( ) => {
1245
+ describe ( 'IgxPivotGrid APIs #pivotGrid' , ( ) => {
1245
1246
let fixture : ComponentFixture < any > ;
1246
1247
let pivotGrid : IgxPivotGridComponent ;
1247
1248
@@ -1433,4 +1434,71 @@ fdescribe('IgxPivotGrid APIs #pivotGrid', () => {
1433
1434
const first = rowHeaders . map ( x => x . componentInstance . column . header ) [ 0 ] ;
1434
1435
expect ( first ) . toBe ( 'All Cities' ) ;
1435
1436
} ) ;
1437
+
1438
+ it ( 'should allow inserting new value at index.' , ( ) => {
1439
+ const value = {
1440
+ member : 'Date' ,
1441
+ aggregate : {
1442
+ aggregator : IgxPivotDateAggregate . latest ,
1443
+ key : 'LATEST' ,
1444
+ label : 'Latest'
1445
+ } ,
1446
+ enabled : true
1447
+ } ;
1448
+ pivotGrid . insertValueAt ( value , 1 ) ;
1449
+ fixture . detectChanges ( ) ;
1450
+ expect ( pivotGrid . values . length ) . toBe ( 3 ) ;
1451
+ expect ( pivotGrid . values [ 1 ] . member ) . toBe ( 'Date' ) ;
1452
+ expect ( pivotGrid . columns . length ) . toBe ( 20 ) ;
1453
+ } ) ;
1454
+
1455
+ it ( 'should allow removing value.' , ( ) => {
1456
+ pivotGrid . removeValue ( pivotGrid . values [ 1 ] ) ;
1457
+ fixture . detectChanges ( ) ;
1458
+ expect ( pivotGrid . pivotConfiguration . values . length ) . toBe ( 1 ) ;
1459
+ expect ( pivotGrid . values [ 0 ] . member ) . toBe ( 'UnitsSold' ) ;
1460
+ expect ( pivotGrid . columns . length ) . toBe ( 5 ) ;
1461
+ } ) ;
1462
+
1463
+ it ( 'should allow toggling value.' , ( ) => {
1464
+ // toggle off
1465
+ pivotGrid . toggleValue ( pivotGrid . pivotConfiguration . values [ 1 ] ) ;
1466
+ fixture . detectChanges ( ) ;
1467
+ expect ( pivotGrid . pivotConfiguration . values . length ) . toBe ( 2 ) ;
1468
+ expect ( pivotGrid . values . length ) . toBe ( 1 ) ;
1469
+ expect ( pivotGrid . values [ 0 ] . member ) . toBe ( 'UnitsSold' ) ;
1470
+ expect ( pivotGrid . columns . length ) . toBe ( 5 ) ;
1471
+ // toggle on
1472
+ pivotGrid . toggleValue ( pivotGrid . pivotConfiguration . values [ 1 ] ) ;
1473
+ fixture . detectChanges ( ) ;
1474
+ expect ( pivotGrid . pivotConfiguration . values . length ) . toBe ( 2 ) ;
1475
+ expect ( pivotGrid . values . length ) . toBe ( 2 ) ;
1476
+ expect ( pivotGrid . values [ 0 ] . member ) . toBe ( 'UnitsSold' ) ;
1477
+ expect ( pivotGrid . values [ 1 ] . member ) . toBe ( 'AmountOfSale' ) ;
1478
+ expect ( pivotGrid . columns . length ) . toBe ( 15 ) ;
1479
+ } ) ;
1480
+
1481
+ it ( 'should allow moving value.' , ( ) => {
1482
+ const val = pivotGrid . pivotConfiguration . values [ 0 ] ;
1483
+ // move after
1484
+ pivotGrid . moveValue ( val , 1 ) ;
1485
+ fixture . detectChanges ( ) ;
1486
+
1487
+ expect ( pivotGrid . values [ 0 ] . member ) . toBe ( 'AmountOfSale' ) ;
1488
+ expect ( pivotGrid . values [ 1 ] . member ) . toBe ( 'UnitsSold' ) ;
1489
+
1490
+ let valueCols = pivotGrid . columns . filter ( x => x . level === 1 ) ;
1491
+ expect ( valueCols [ 0 ] . header ) . toBe ( 'Amount of Sale' ) ;
1492
+ expect ( valueCols [ 1 ] . header ) . toBe ( 'UnitsSold' ) ;
1493
+
1494
+ // move before
1495
+ pivotGrid . moveValue ( val , 0 ) ;
1496
+ fixture . detectChanges ( ) ;
1497
+
1498
+ expect ( pivotGrid . values [ 0 ] . member ) . toBe ( 'UnitsSold' ) ;
1499
+ expect ( pivotGrid . values [ 1 ] . member ) . toBe ( 'AmountOfSale' ) ;
1500
+ valueCols = pivotGrid . columns . filter ( x => x . level === 1 ) ;
1501
+ expect ( valueCols [ 0 ] . header ) . toBe ( 'UnitsSold' ) ;
1502
+ expect ( valueCols [ 1 ] . header ) . toBe ( 'Amount of Sale' ) ;
1503
+ } ) ;
1436
1504
} ) ;
0 commit comments