@@ -6,6 +6,7 @@ import { IgxPivotNumericAggregate } from './pivot-grid-aggregate';
6
6
import { IPivotConfiguration } from './pivot-grid.interface' ;
7
7
import { IgxPivotColumnPipe , IgxPivotRowExpansionPipe , IgxPivotRowPipe } from './pivot-grid.pipes' ;
8
8
import { PivotGridFunctions } from '../../test-utils/pivot-grid-functions.spec' ;
9
+ import { DATA } from 'src/app/shared/pivot-data' ;
9
10
10
11
describe ( 'Pivot pipes #pivotGrid' , ( ) => {
11
12
let rowPipe : IgxPivotRowPipe ;
@@ -1532,4 +1533,117 @@ describe('Pivot pipes #pivotGrid', () => {
1532
1533
{ Years : '2021' , AllProduct : 'All Products' , Discontinued : 'false' , Country : 'USA' , SellerName : 'John' }
1533
1534
] ) ;
1534
1535
} ) ;
1536
+ // automation for https://github.com/IgniteUI/igniteui-angular/issues/10545
1537
+ it ( 'should generate last dimension values for all records.' , ( ) => {
1538
+ data = [
1539
+ {
1540
+ ProductCategory : 'Clothing' , UnitPrice : 12.81 , SellerName : 'Stanley' ,
1541
+ Country : 'Bulgaria' , City : 'Sofia' , Date : '01/01/2021' , UnitsSold : 282
1542
+ } ,
1543
+ {
1544
+ ProductCategory : 'Clothing' , UnitPrice : 49.57 , SellerName : 'Elisa' ,
1545
+ Country : 'USA' , City : 'New York' , Date : '01/05/2019' , UnitsSold : 296
1546
+ } ,
1547
+ {
1548
+ ProductCategory : 'Bikes' , UnitPrice : 3.56 , SellerName : 'Lydia' ,
1549
+ Country : 'Uruguay' , City : 'Ciudad de la Costa' , Date : '01/06/2020' , UnitsSold : 68
1550
+ } ,
1551
+ {
1552
+ ProductCategory : 'Accessories' , UnitPrice : 85.58 , SellerName : 'David' ,
1553
+ Country : 'USA' , City : 'New York' , Date : '04/07/2021' , UnitsSold : 293
1554
+ } ,
1555
+ {
1556
+ ProductCategory : 'Components' , UnitPrice : 18.13 , SellerName : 'John' ,
1557
+ Country : 'USA' , City : 'New York' , Date : '12/08/2021' , UnitsSold : 240
1558
+ } ,
1559
+ {
1560
+ ProductCategory : 'Clothing' , UnitPrice : 68.33 , SellerName : 'Larry' ,
1561
+ Country : 'Uruguay' , City : 'Ciudad de la Costa' , Date : '05/12/2020' , UnitsSold : 456
1562
+ } ,
1563
+ {
1564
+ ProductCategory : 'Clothing' , UnitPrice : 16.05 , SellerName : 'Walter' ,
1565
+ Country : 'Bulgaria' , City : 'Plovdiv' , Date : '02/19/2020' , UnitsSold : 492
1566
+ } ] ;
1567
+ pivotConfig . columns = [ {
1568
+ memberName : 'Country' ,
1569
+ enabled : true
1570
+ } ] ;
1571
+ pivotConfig . rows = [
1572
+ new IgxPivotDateDimension (
1573
+ {
1574
+ memberName : 'Date' ,
1575
+ enabled : true
1576
+ } ,
1577
+ {
1578
+ months : false
1579
+ }
1580
+ ) ,
1581
+ {
1582
+ memberName : 'City' ,
1583
+ enabled : true
1584
+ } ,
1585
+ {
1586
+ memberFunction : ( ) => 'All' ,
1587
+ memberName : 'AllProducts' ,
1588
+ enabled : true ,
1589
+ childLevel : {
1590
+ memberFunction : ( recData ) => recData . ProductCategory ,
1591
+ memberName : 'ProductCategory' ,
1592
+ enabled : true
1593
+ }
1594
+ } ,
1595
+ {
1596
+ memberName : 'SellerName' ,
1597
+ enabled : true
1598
+ }
1599
+ ] ;
1600
+ const rowPipeResult = rowPipe . transform ( data , pivotConfig , expansionStates ) ;
1601
+ const columnPipeResult = columnPipe . transform ( rowPipeResult , pivotConfig , new Map < any , boolean > ( ) ) ;
1602
+ const rowStatePipeResult = rowStatePipe . transform ( columnPipeResult , pivotConfig , expansionStates , true ) ;
1603
+ const sellers = rowStatePipeResult . map ( x => x . SellerName ) ;
1604
+ // there should be no empty values.
1605
+ expect ( sellers . filter ( x => x === undefined ) . length ) . toBe ( 0 ) ;
1606
+ } ) ;
1607
+
1608
+ // automation for https://github.com/IgniteUI/igniteui-angular/issues/10662
1609
+ it ( 'should retain processed values for last dimension when bound to complex object.' , ( ) => {
1610
+ data = DATA ;
1611
+ pivotConfig . rows = [
1612
+ {
1613
+ memberName : 'Date' ,
1614
+ enabled : true ,
1615
+ } ,
1616
+ {
1617
+ memberName : 'AllProduct' ,
1618
+ memberFunction : ( ) => 'All Products' ,
1619
+ enabled : true ,
1620
+ childLevel :
1621
+ {
1622
+
1623
+ memberName : 'Product' ,
1624
+ memberFunction : ( recData ) => recData . Product . Name ,
1625
+ enabled : true
1626
+ }
1627
+ } ,
1628
+ {
1629
+ memberName : 'AllSeller' ,
1630
+ memberFunction : ( ) => 'All Sellers' ,
1631
+ enabled : true ,
1632
+ childLevel :
1633
+ {
1634
+ memberName : 'Seller' ,
1635
+ memberFunction : ( recData ) => recData . Seller . Name ,
1636
+ enabled : true ,
1637
+ } ,
1638
+ } ,
1639
+ ] ;
1640
+
1641
+ const rowPipeResult = rowPipe . transform ( data , pivotConfig , expansionStates ) ;
1642
+ const columnPipeResult = columnPipe . transform ( rowPipeResult , pivotConfig , new Map < any , boolean > ( ) ) ;
1643
+ const rowStatePipeResult = rowStatePipe . transform ( columnPipeResult , pivotConfig , expansionStates , true ) ;
1644
+
1645
+ const res = rowStatePipeResult . filter ( x => x . AllSeller === undefined ) . map ( x => x . Seller ) ;
1646
+ // all values should be strings as the result of the processed member function is string.
1647
+ expect ( res . filter ( x => typeof x !== 'string' ) . length ) . toBe ( 0 ) ;
1648
+ } ) ;
1535
1649
} ) ;
0 commit comments