@@ -5,6 +5,7 @@ import { IgxPivotDateDimension } from './pivot-grid-dimensions';
5
5
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
+ import { DATA } from 'src/app/shared/pivot-data' ;
8
9
9
10
describe ( 'Pivot pipes #pivotGrid' , ( ) => {
10
11
let rowPipe : IgxPivotRowPipe ;
@@ -837,4 +838,118 @@ describe('Pivot pipes #pivotGrid', () => {
837
838
expect ( rowStatePipeResult [ 13 ] [ 'Years' ] ) . not . toBeDefined ( ) ;
838
839
expect ( rowStatePipeResult [ 13 ] [ 'Date' ] ) . toEqual ( '01/01/2021' ) ;
839
840
} ) ;
841
+
842
+ // automation for https://github.com/IgniteUI/igniteui-angular/issues/10545
843
+ it ( 'should generate last dimension values for all records.' , ( ) => {
844
+ data = [
845
+ {
846
+ ProductCategory : 'Clothing' , UnitPrice : 12.81 , SellerName : 'Stanley' ,
847
+ Country : 'Bulgaria' , City : 'Sofia' , Date : '01/01/2021' , UnitsSold : 282
848
+ } ,
849
+ {
850
+ ProductCategory : 'Clothing' , UnitPrice : 49.57 , SellerName : 'Elisa' ,
851
+ Country : 'USA' , City : 'New York' , Date : '01/05/2019' , UnitsSold : 296
852
+ } ,
853
+ {
854
+ ProductCategory : 'Bikes' , UnitPrice : 3.56 , SellerName : 'Lydia' ,
855
+ Country : 'Uruguay' , City : 'Ciudad de la Costa' , Date : '01/06/2020' , UnitsSold : 68
856
+ } ,
857
+ {
858
+ ProductCategory : 'Accessories' , UnitPrice : 85.58 , SellerName : 'David' ,
859
+ Country : 'USA' , City : 'New York' , Date : '04/07/2021' , UnitsSold : 293
860
+ } ,
861
+ {
862
+ ProductCategory : 'Components' , UnitPrice : 18.13 , SellerName : 'John' ,
863
+ Country : 'USA' , City : 'New York' , Date : '12/08/2021' , UnitsSold : 240
864
+ } ,
865
+ {
866
+ ProductCategory : 'Clothing' , UnitPrice : 68.33 , SellerName : 'Larry' ,
867
+ Country : 'Uruguay' , City : 'Ciudad de la Costa' , Date : '05/12/2020' , UnitsSold : 456
868
+ } ,
869
+ {
870
+ ProductCategory : 'Clothing' , UnitPrice : 16.05 , SellerName : 'Walter' ,
871
+ Country : 'Bulgaria' , City : 'Plovdiv' , Date : '02/19/2020' , UnitsSold : 492
872
+ } ] ;
873
+ pivotConfig . columns = [ {
874
+ memberName : 'Country' ,
875
+ enabled : true
876
+ } ] ;
877
+ pivotConfig . rows = [
878
+ new IgxPivotDateDimension (
879
+ {
880
+ memberName : 'Date' ,
881
+ enabled : true
882
+ } ,
883
+ {
884
+ months : false
885
+ }
886
+ ) ,
887
+ {
888
+ memberName : 'City' ,
889
+ enabled : true
890
+ } ,
891
+ {
892
+ memberFunction : ( ) => 'All' ,
893
+ memberName : 'AllProducts' ,
894
+ enabled : true ,
895
+ childLevel : {
896
+ memberFunction : ( data ) => data . ProductCategory ,
897
+ memberName : 'ProductCategory' ,
898
+ enabled : true
899
+ }
900
+ } ,
901
+ {
902
+ memberName : 'SellerName' ,
903
+ enabled : true
904
+ }
905
+ ] ;
906
+ const rowPipeResult = rowPipe . transform ( data , pivotConfig , expansionStates ) ;
907
+ const columnPipeResult = columnPipe . transform ( rowPipeResult , pivotConfig , new Map < any , boolean > ( ) ) ;
908
+ const rowStatePipeResult = rowStatePipe . transform ( columnPipeResult , pivotConfig , expansionStates , true ) ;
909
+ const sellers = rowStatePipeResult . map ( x => x . SellerName ) ;
910
+ // there should be no empty values.
911
+ expect ( sellers . filter ( x => x === undefined ) . length ) . toBe ( 0 ) ;
912
+ } ) ;
913
+
914
+ // automation for https://github.com/IgniteUI/igniteui-angular/issues/10662
915
+ it ( 'should retain processed values for last dimension when bound to complex object.' , ( ) => {
916
+ data = DATA ;
917
+ pivotConfig . rows = [
918
+ {
919
+ memberName : 'Date' ,
920
+ enabled : true ,
921
+ } ,
922
+ {
923
+ memberName : 'AllProduct' ,
924
+ memberFunction : ( ) => 'All Products' ,
925
+ enabled : true ,
926
+ childLevel :
927
+ {
928
+
929
+ memberName : 'Product' ,
930
+ memberFunction : ( data ) => data . Product . Name ,
931
+ enabled : true
932
+ }
933
+ } ,
934
+ {
935
+ memberName : 'AllSeller' ,
936
+ memberFunction : ( ) => 'All Sellers' ,
937
+ enabled : true ,
938
+ childLevel :
939
+ {
940
+ memberName : 'Seller' ,
941
+ memberFunction : ( data ) => data . Seller . Name ,
942
+ enabled : true ,
943
+ } ,
944
+ } ,
945
+ ] ;
946
+
947
+ const rowPipeResult = rowPipe . transform ( data , pivotConfig , expansionStates ) ;
948
+ const columnPipeResult = columnPipe . transform ( rowPipeResult , pivotConfig , new Map < any , boolean > ( ) ) ;
949
+ const rowStatePipeResult = rowStatePipe . transform ( columnPipeResult , pivotConfig , expansionStates , true ) ;
950
+
951
+ const res = rowStatePipeResult . filter ( x => x . AllSeller === undefined ) . map ( x => x . Seller ) ;
952
+ // all values should be strings as the result of the processed member function is string.
953
+ expect ( res . filter ( x => typeof x !== 'string' ) . length ) . toBe ( 0 ) ;
954
+ } ) ;
840
955
} ) ;
0 commit comments