@@ -16,15 +16,19 @@ describe('Pivot pipes', () => {
16
16
configureTestSuite ( ) ;
17
17
beforeEach ( ( ) => {
18
18
data = [
19
- { ProductCategory : 'Clothing' , UnitPrice : 12.81 , SellerName : 'Stanley' ,
20
- Country : 'Bulgaria' , Date : '01/01/2021' , UnitsSold : 282 } ,
19
+ {
20
+ ProductCategory : 'Clothing' , UnitPrice : 12.81 , SellerName : 'Stanley' ,
21
+ Country : 'Bulgaria' , Date : '01/01/2021' , UnitsSold : 282
22
+ } ,
21
23
{ ProductCategory : 'Clothing' , UnitPrice : 49.57 , SellerName : 'Elisa' , Country : 'USA' , Date : '01/05/2019' , UnitsSold : 296 } ,
22
24
{ ProductCategory : 'Bikes' , UnitPrice : 3.56 , SellerName : 'Lydia' , Country : 'Uruguay' , Date : '01/06/2020' , UnitsSold : 68 } ,
23
25
{ ProductCategory : 'Accessories' , UnitPrice : 85.58 , SellerName : 'David' , Country : 'USA' , Date : '04/07/2021' , UnitsSold : 293 } ,
24
26
{ ProductCategory : 'Components' , UnitPrice : 18.13 , SellerName : 'John' , Country : 'USA' , Date : '12/08/2021' , UnitsSold : 240 } ,
25
27
{ ProductCategory : 'Clothing' , UnitPrice : 68.33 , SellerName : 'Larry' , Country : 'Uruguay' , Date : '05/12/2020' , UnitsSold : 456 } ,
26
- { ProductCategory : 'Clothing' , UnitPrice : 16.05 , SellerName : 'Walter' ,
27
- Country : 'Bulgaria' , Date : '02/19/2020' , UnitsSold : 492 } ] ;
28
+ {
29
+ ProductCategory : 'Clothing' , UnitPrice : 16.05 , SellerName : 'Walter' ,
30
+ Country : 'Bulgaria' , Date : '02/19/2020' , UnitsSold : 492
31
+ } ] ;
28
32
pivotConfig = {
29
33
columns : [ {
30
34
memberName : 'All' ,
@@ -196,7 +200,8 @@ describe('Pivot pipes', () => {
196
200
{ ProductCategory : 'Components' , All : 240 , 'All-USA' : 240 , ProductCategory_level : 1 } ] ) ;
197
201
} ) ;
198
202
199
- it ( 'transforms flat data to pivot data multiple row dimensions' , ( ) => {
203
+ // xit-ing because of https://github.com/IgniteUI/igniteui-angular/issues/10546
204
+ xit ( 'transforms flat data to pivot data multiple row dimensions' , ( ) => {
200
205
pivotConfig . rows = [
201
206
{
202
207
memberName : 'ProductCategory' ,
@@ -398,10 +403,14 @@ describe('Pivot pipes', () => {
398
403
// same data but expanded
399
404
expect ( rowStateResult ) . toEqual (
400
405
[
401
- { 'All' : 2127 , 'AllCategory' : 'All' , 'All-Bulgaria' : 774 , 'All-USA' : 829 ,
402
- 'All-Uruguay' : 524 , 'AllCategory_level' : 0 } ,
403
- { 'ProductCategory' : 'Clothing' , 'All' : 1526 , 'All-Bulgaria' : 774 ,
404
- 'All-USA' : 296 , 'All-Uruguay' : 456 , 'ProductCategory_level' : 1 } ,
406
+ {
407
+ 'All' : 2127 , 'AllCategory' : 'All' , 'All-Bulgaria' : 774 , 'All-USA' : 829 ,
408
+ 'All-Uruguay' : 524 , 'AllCategory_level' : 0
409
+ } ,
410
+ {
411
+ 'ProductCategory' : 'Clothing' , 'All' : 1526 , 'All-Bulgaria' : 774 ,
412
+ 'All-USA' : 296 , 'All-Uruguay' : 456 , 'ProductCategory_level' : 1
413
+ } ,
405
414
{ 'ProductCategory' : 'Bikes' , 'All' : 68 , 'All-Uruguay' : 68 , 'ProductCategory_level' : 1 } ,
406
415
{ 'ProductCategory' : 'Accessories' , 'All' : 293 , 'All-USA' : 293 , 'ProductCategory_level' : 1 } ,
407
416
{ 'ProductCategory' : 'Components' , 'All' : 240 , 'All-USA' : 240 , 'ProductCategory_level' : 1 } ]
@@ -452,58 +461,178 @@ describe('Pivot pipes', () => {
452
461
] ;
453
462
454
463
const rowPipeResult = rowPipe . transform ( data , pivotConfig , expansionStates ) ;
455
- const columnPipeResult = columnPipe . transform ( rowPipeResult , pivotConfig , new Map < any , boolean > ( ) ) ;
456
- const rowStatePipeResult = rowStatePipe . transform ( columnPipeResult , pivotConfig , expansionStates ) ;
457
464
458
- expect ( rowStatePipeResult [ 0 ] ) . toEqual (
465
+ expect ( rowPipeResult [ 0 ] ) . toEqual (
459
466
{
460
- AllPeriods : 'All Periods' ,
461
- AllPeriods_records : [
467
+ 'AllPeriods' : 'All Periods' , 'AllPeriods_records' : [
462
468
{
463
- Years : '2021' ,
464
- level : 1 ,
465
- Years_level : 1
469
+ 'Years' : '2021' , 'records' : [
470
+ {
471
+ 'ProductCategory' : 'Clothing' , 'UnitPrice' : 12.81 , 'SellerName' : 'Stanley' , 'Country' : 'Bulgaria' ,
472
+ 'City' : 'Sofia' , 'Date' : '01/01/2021' , 'UnitsSold' : 282
473
+ } ,
474
+ {
475
+ 'ProductCategory' : 'Accessories' , 'UnitPrice' : 85.58 , 'SellerName' : 'David' , 'Country' : 'USA' ,
476
+ 'City' : 'New York' , 'Date' : '04/07/2021' , 'UnitsSold' : 293
477
+ } ,
478
+ {
479
+ 'ProductCategory' : 'Components' , 'UnitPrice' : 18.13 , 'SellerName' : 'John' , 'Country' : 'USA' ,
480
+ 'City' : 'New York' , 'Date' : '12/08/2021' , 'UnitsSold' : 240
481
+ }
482
+ ] , 'Years_records' : [
483
+ {
484
+ 'Date' : '01/01/2021' , 'records' : [
485
+ {
486
+ 'ProductCategory' : 'Clothing' , 'UnitPrice' : 12.81 , 'SellerName' : 'Stanley' , 'Country' : 'Bulgaria' ,
487
+ 'City' : 'Sofia' , 'Date' : '01/01/2021' , 'UnitsSold' : 282
488
+ }
489
+ ] , 'Date_records' : [
490
+ {
491
+ 'ProductCategory' : 'Clothing' , 'UnitPrice' : 12.81 , 'SellerName' : 'Stanley' ,
492
+ 'Country' : 'Bulgaria' , 'City' : 'Sofia' , 'Date' : '01/01/2021' ,
493
+ 'UnitsSold' : 282
494
+ } ] , 'level' : 2
495
+ } , {
496
+ 'Date' : '04/07/2021' , 'records' : [
497
+ {
498
+ 'ProductCategory' : 'Accessories' , 'UnitPrice' : 85.58 , 'SellerName' : 'David' ,
499
+ 'Country' : 'USA' , 'City' : 'New York' ,
500
+ 'Date' : '04/07/2021' , 'UnitsSold' : 293
501
+ }
502
+ ] , 'Date_records' : [
503
+ {
504
+ 'ProductCategory' : 'Accessories' , 'UnitPrice' : 85.58 , 'SellerName' : 'David' , 'Country' : 'USA' ,
505
+ 'City' : 'New York' , 'Date' : '04/07/2021' ,
506
+ 'UnitsSold' : 293
507
+ }
508
+ ] , 'level' : 2
509
+ } ,
510
+ {
511
+ 'Date' : '12/08/2021' , 'records' : [
512
+ {
513
+ 'ProductCategory' : 'Components' , 'UnitPrice' : 18.13 , 'SellerName' : 'John' , 'Country' : 'USA' ,
514
+ 'City' : 'New York' , 'Date' : '12/08/2021' , 'UnitsSold' : 240
515
+ }
516
+ ] , 'Date_records' : [
517
+ {
518
+ 'ProductCategory' : 'Components' , 'UnitPrice' : 18.13 , 'SellerName' : 'John' , 'Country' : 'USA' ,
519
+ 'City' : 'New York' , 'Date' : '12/08/2021' , 'UnitsSold' : 240
520
+ }
521
+ ] , 'level' : 2
522
+ }
523
+ ] , 'level' : 1
466
524
} ,
467
525
{
468
- Date : '01/01/2021' ,
469
- Date_level : 2 ,
526
+ 'Years' : '2019' ,
527
+ 'records' : [
528
+ {
529
+ 'ProductCategory' : 'Clothing' , 'UnitPrice' : 49.57 , 'SellerName' : 'Elisa' , 'Country' : 'USA' ,
530
+ 'City' : 'New York' , 'Date' : '01/05/2019' , 'UnitsSold' : 296
531
+ }
532
+ ] , 'Years_records' : [
533
+ {
534
+ 'Date' : '01/05/2019' , 'records' : [
535
+ {
536
+ 'ProductCategory' : 'Clothing' , 'UnitPrice' : 49.57 , 'SellerName' : 'Elisa' ,
537
+ 'Country' : 'USA' , 'City' : 'New York' ,
538
+ 'Date' : '01/05/2019' , 'UnitsSold' : 296
539
+ }
540
+ ] , 'Date_records' : [
541
+ {
542
+ 'ProductCategory' : 'Clothing' , 'UnitPrice' : 49.57 , 'SellerName' : 'Elisa' , 'Country' : 'USA' ,
543
+ 'City' : 'New York' ,
544
+ 'Date' : '01/05/2019' , 'UnitsSold' : 296
545
+ } ] , 'level' : 2
546
+ } ] , 'level' : 1
470
547
} ,
471
548
{
472
- Date : '04/07/2021' ,
473
- Date_level : 2 ,
474
- } ,
549
+ 'Years' : '2020' , 'records' : [
550
+ {
551
+ 'ProductCategory' : 'Bikes' , 'UnitPrice' : 3.56 , 'SellerName' : 'Lydia' , 'Country' : 'Uruguay' ,
552
+ 'City' : 'Ciudad de la Costa' , 'Date' : '01/06/2020' , 'UnitsSold' : 68
553
+ } ,
554
+ {
555
+ 'ProductCategory' : 'Clothing' , 'UnitPrice' : 68.33 ,
556
+ 'SellerName' : 'Larry' , 'Country' : 'Uruguay' , 'City' : 'Ciudad de la Costa' ,
557
+ 'Date' : '05/12/2020' , 'UnitsSold' : 456
558
+ } ,
559
+ {
560
+ 'ProductCategory' : 'Clothing' , 'UnitPrice' : 16.05 , 'SellerName' : 'Walter' , 'Country' : 'Bulgaria' ,
561
+ 'City' : 'Plovdiv' , 'Date' : '02/19/2020' , 'UnitsSold' : 492
562
+ }
563
+ ] , 'Years_records' : [
564
+ {
565
+ 'Date' : '01/06/2020' , 'records' : [
566
+ {
567
+ 'ProductCategory' : 'Bikes' , 'UnitPrice' : 3.56 , 'SellerName' : 'Lydia' , 'Country' : 'Uruguay' ,
568
+ 'City' : 'Ciudad de la Costa' , 'Date' : '01/06/2020' , 'UnitsSold' : 68
569
+ }
570
+ ] , 'Date_records' : [
571
+ {
572
+ 'ProductCategory' : 'Bikes' , 'UnitPrice' : 3.56 , 'SellerName' : 'Lydia' , 'Country' : 'Uruguay' ,
573
+ 'City' : 'Ciudad de la Costa' , 'Date' : '01/06/2020' , 'UnitsSold' : 68
574
+ }
575
+ ] , 'level' : 2
576
+ } ,
577
+ {
578
+ 'Date' : '05/12/2020' , 'records' : [
579
+ {
580
+ 'ProductCategory' : 'Clothing' , 'UnitPrice' : 68.33 , 'SellerName' : 'Larry' , 'Country' : 'Uruguay' ,
581
+ 'City' : 'Ciudad de la Costa' , 'Date' : '05/12/2020' , 'UnitsSold' : 456
582
+ }
583
+ ] , 'Date_records' : [
584
+ {
585
+ 'ProductCategory' : 'Clothing' , 'UnitPrice' : 68.33 , 'SellerName' : 'Larry' , 'Country' : 'Uruguay' ,
586
+ 'City' : 'Ciudad de la Costa' , 'Date' : '05/12/2020' , 'UnitsSold' : 456
587
+ }
588
+ ] , 'level' : 2
589
+ } ,
590
+ {
591
+ 'Date' : '02/19/2020' , 'records' : [
592
+ {
593
+ 'ProductCategory' : 'Clothing' , 'UnitPrice' : 16.05 , 'SellerName' : 'Walter' , 'Country' : 'Bulgaria' ,
594
+ 'City' : 'Plovdiv' , 'Date' : '02/19/2020' , 'UnitsSold' : 492
595
+ }
596
+ ] , 'Date_records' : [
597
+ {
598
+ 'ProductCategory' : 'Clothing' , 'UnitPrice' : 16.05 , 'SellerName' : 'Walter' ,
599
+ 'Country' : 'Bulgaria' , 'City' : 'Plovdiv' , 'Date' : '02/19/2020' , 'UnitsSold' : 492
600
+ }
601
+ ] , 'level' : 2
602
+ }
603
+ ] , 'level' : 1
604
+ }
605
+ ] , 'level' : 0 , 'records' : [
475
606
{
476
- Date : '12/08/2021 ' ,
477
- Date_level : 2 ,
607
+ 'ProductCategory' : 'Clothing' , 'UnitPrice' : 12.81 , 'SellerName' : 'Stanley' , 'Country' : 'Bulgaria' , 'City' : 'Sofia ',
608
+ 'Date' : '01/01/2021' , 'UnitsSold' : 282
478
609
} ,
479
610
{
480
- Years : '2019 ' ,
481
- Years_level : 1
611
+ 'ProductCategory' : 'Accessories' , 'UnitPrice' : 85.58 , 'SellerName' : 'David' , 'Country' : 'USA ',
612
+ 'City' : 'New York' , 'Date' : '04/07/2021' , 'UnitsSold' : 293
482
613
} ,
483
614
{
484
- Date : '01/05/2019 ' ,
485
- Date_level : 2
615
+ 'ProductCategory' : 'Components' , 'UnitPrice' : 18.13 , 'SellerName' : 'John' , 'Country' : 'USA ',
616
+ 'City' : 'New York' , 'Date' : '12/08/2021' , 'UnitsSold' : 240
486
617
} ,
487
618
{
488
- Years : '2020 ' ,
489
- Years_level : 1
619
+ 'ProductCategory' : 'Clothing' , 'UnitPrice' : 49.57 , 'SellerName' : 'Elisa' , 'Country' : 'USA ',
620
+ 'City' : 'New York' , 'Date' : '01/05/2019' , 'UnitsSold' : 296
490
621
} ,
491
622
{
492
- Date : '01/06/2020 ' ,
493
- Date_level : 2
623
+ 'ProductCategory' : 'Bikes' , 'UnitPrice' : 3.56 , 'SellerName' : 'Lydia' , 'Country' : 'Uruguay ',
624
+ 'City' : 'Ciudad de la Costa' , 'Date' : '01/06/2020' , 'UnitsSold' : 68
494
625
} ,
495
626
{
496
- Date : '05/12/2020 ' ,
497
- Date_level : 2
627
+ 'ProductCategory' : 'Clothing' , 'UnitPrice' : 68.33 , 'SellerName' : 'Larry' , 'Country' : 'Uruguay ',
628
+ 'City' : 'Ciudad de la Costa' , 'Date' : '05/12/2020' , 'UnitsSold' : 456
498
629
} ,
499
630
{
500
- Date : '02/19/2020' ,
501
- level : 2 ,
502
- Date_level : 2
503
- } ] ,
504
- level : 0 ,
505
- AllPeriods_level : 0
506
- } ) ;
631
+ 'ProductCategory' : 'Clothing' , 'UnitPrice' : 16.05 , 'SellerName' : 'Walter' , 'Country' : 'Bulgaria' ,
632
+ 'City' : 'Plovdiv' , 'Date' : '02/19/2020' , 'UnitsSold' : 492
633
+ } ]
634
+ }
635
+ ) ;
507
636
} ) ;
508
637
509
638
it ( 'should generate correct levels when using predefined date dimension with other row dimensions' , ( ) => {
@@ -566,69 +695,34 @@ describe('Pivot pipes', () => {
566
695
const rowStatePipeResult = rowStatePipe . transform ( columnPipeResult , pivotConfig , expansionStates ) ;
567
696
expect ( rowStatePipeResult . length ) . toEqual ( 44 ) ;
568
697
expect ( rowStatePipeResult [ 0 ] [ 'AllPeriods' ] ) . toEqual ( 'All Periods' ) ;
569
- expect ( rowStatePipeResult [ 0 ] [ 'AllPeriods_records' ] . length ) . toEqual ( 10 ) ;
570
698
expect ( rowStatePipeResult [ 0 ] [ 'AllProducts' ] ) . toEqual ( 'All' ) ;
571
699
expect ( rowStatePipeResult [ 0 ] [ 'ProductCategory' ] ) . not . toBeDefined ( ) ;
572
- expect ( rowStatePipeResult [ 0 ] [ 'AllProducts_records' ] . length ) . toEqual ( 1 ) ;
573
- expect ( rowStatePipeResult [ 0 ] [ 'AllProducts_records' ] [ 0 ] [ 'ProductCategory' ] ) . toEqual ( 'Clothing' ) ;
574
700
expect ( rowStatePipeResult [ 0 ] [ 'City' ] ) . toEqual ( 'Sofia' ) ;
575
- expect ( rowStatePipeResult [ 0 ] [ 'City_records' ] . length ) . toEqual ( 1 ) ;
576
- expect ( rowStatePipeResult [ 0 ] [ 'level' ] ) . toEqual ( 0 ) ;
577
701
578
702
expect ( rowStatePipeResult [ 1 ] [ 'AllPeriods' ] ) . toEqual ( 'All Periods' ) ;
579
- expect ( rowStatePipeResult [ 1 ] [ 'AllPeriods_records' ] . length ) . toEqual ( 10 ) ;
580
703
expect ( rowStatePipeResult [ 1 ] [ 'AllProducts' ] ) . not . toBeDefined ( ) ;
581
- expect ( rowStatePipeResult [ 1 ] [ 'AllProducts_records' ] . length ) . toEqual ( 0 ) ;
582
704
expect ( rowStatePipeResult [ 1 ] [ 'ProductCategory' ] ) . toEqual ( 'Clothing' ) ;
583
705
expect ( rowStatePipeResult [ 1 ] [ 'City' ] ) . toEqual ( 'Sofia' ) ;
584
- expect ( rowStatePipeResult [ 1 ] [ 'City_records' ] . length ) . toEqual ( 1 ) ;
585
- expect ( rowStatePipeResult [ 1 ] [ 'level' ] ) . toEqual ( 1 ) ;
586
-
587
- expect ( rowStatePipeResult [ 2 ] [ 'level' ] ) . toEqual ( 0 ) ;
588
706
589
707
expect ( rowStatePipeResult [ 10 ] [ 'AllPeriods' ] ) . not . toBeDefined ( ) ;
590
- expect ( rowStatePipeResult [ 10 ] [ 'AllPeriods_records' ] ) . not . toBeDefined ( ) ;
591
708
expect ( rowStatePipeResult [ 10 ] [ 'ProductCategory' ] ) . not . toBeDefined ( ) ;
592
709
expect ( rowStatePipeResult [ 10 ] [ 'AllProducts' ] ) . toEqual ( 'All' ) ;
593
- expect ( rowStatePipeResult [ 10 ] [ 'AllProducts_records' ] . length ) . toEqual ( 1 ) ;
594
- expect ( rowStatePipeResult [ 10 ] [ 'AllProducts_records' ] [ 0 ] [ 'ProductCategory' ] ) . toEqual ( 'Clothing' ) ;
595
710
expect ( rowStatePipeResult [ 10 ] [ 'City' ] ) . toEqual ( 'Sofia' ) ;
596
- expect ( rowStatePipeResult [ 10 ] [ 'City_records' ] . length ) . toEqual ( 2 ) ;
597
711
expect ( rowStatePipeResult [ 10 ] [ 'Years' ] ) . toEqual ( '2021' ) ;
598
- expect ( rowStatePipeResult [ 10 ] [ 'Years_records' ] . length ) . toEqual ( 3 ) ;
599
712
expect ( rowStatePipeResult [ 10 ] [ 'Years_level' ] ) . toEqual ( 1 ) ;
600
- expect ( rowStatePipeResult [ 10 ] [ 'level' ] ) . toEqual ( 0 ) ;
601
713
602
714
expect ( rowStatePipeResult [ 11 ] [ 'AllPeriods' ] ) . not . toBeDefined ( ) ;
603
- expect ( rowStatePipeResult [ 11 ] [ 'AllPeriods_records' ] ) . not . toBeDefined ( ) ;
604
715
expect ( rowStatePipeResult [ 11 ] [ 'ProductCategory' ] ) . toEqual ( 'Clothing' ) ;
605
- expect ( rowStatePipeResult [ 11 ] [ 'ProductCategory_records' ] . length ) . toEqual ( 1 ) ;
606
716
expect ( rowStatePipeResult [ 11 ] [ 'AllProducts' ] ) . not . toBeDefined ( ) ;
607
- expect ( rowStatePipeResult [ 11 ] [ 'AllProducts_records' ] . length ) . toEqual ( 0 ) ;
608
717
expect ( rowStatePipeResult [ 11 ] [ 'City' ] ) . toEqual ( 'Sofia' ) ;
609
- expect ( rowStatePipeResult [ 11 ] [ 'City_records' ] . length ) . toEqual ( 2 ) ;
610
718
expect ( rowStatePipeResult [ 11 ] [ 'Years' ] ) . toEqual ( '2021' ) ;
611
- expect ( rowStatePipeResult [ 11 ] [ 'Years_records' ] . length ) . toEqual ( 3 ) ;
612
719
expect ( rowStatePipeResult [ 11 ] [ 'Years_level' ] ) . toEqual ( 1 ) ;
613
- expect ( rowStatePipeResult [ 11 ] [ 'level' ] ) . toEqual ( 1 ) ;
614
720
615
721
expect ( rowStatePipeResult [ 15 ] [ 'AllPeriods' ] ) . not . toBeDefined ( ) ;
616
- expect ( rowStatePipeResult [ 15 ] [ 'AllPeriods_records' ] ) . not . toBeDefined ( ) ;
617
722
expect ( rowStatePipeResult [ 15 ] [ 'ProductCategory' ] ) . not . toBeDefined ( ) ;
618
- expect ( rowStatePipeResult [ 15 ] [ 'ProductCategory_records' ] ) . not . toBeDefined ( ) ;
619
723
expect ( rowStatePipeResult [ 15 ] [ 'AllProducts' ] ) . toEqual ( 'All' ) ;
620
- expect ( rowStatePipeResult [ 15 ] [ 'AllProducts_records' ] . length ) . toEqual ( 1 ) ;
621
724
expect ( rowStatePipeResult [ 15 ] [ 'City' ] ) . toEqual ( 'Sofia' ) ;
622
- expect ( rowStatePipeResult [ 15 ] [ 'City_records' ] . length ) . toEqual ( 1 ) ;
623
725
expect ( rowStatePipeResult [ 15 ] [ 'Years' ] ) . not . toBeDefined ( ) ;
624
- expect ( rowStatePipeResult [ 15 ] [ 'Years_records' ] ) . not . toBeDefined ( ) ;
625
726
expect ( rowStatePipeResult [ 15 ] [ 'Date' ] ) . toEqual ( '01/01/2021' ) ;
626
- expect ( rowStatePipeResult [ 15 ] [ 'Date_records' ] [ 0 ] ) . toEqual (
627
- {
628
- 'ProductCategory' : 'Clothing' , 'UnitPrice' : 12.81 , 'SellerName' : 'Stanley' ,
629
- 'Country' : 'Bulgaria' , 'City' : 'Sofia' , 'Date' : '01/01/2021' , 'UnitsSold' : 282 , 'Date_level' : 2 , 'AllProducts_level' : 0
630
- }
631
- ) ;
632
- expect ( rowStatePipeResult [ 15 ] [ 'level' ] ) . toEqual ( 2 ) ;
633
727
} ) ;
634
728
} ) ;
0 commit comments