@@ -10,6 +10,9 @@ import { IgxHierarchicalGridTestBaseComponent } from '../../../../../test-utils/
1010import { IgxTreeGridSortingComponent , IgxTreeGridPrimaryForeignKeyComponent } from '../../../../../test-utils/tree-grid-components.spec' ;
1111import { CustomSummariesComponent } from 'igniteui-angular/grids/grid/src/grid-summary.spec' ;
1212import { IgxHierarchicalGridComponent } from 'igniteui-angular/grids/hierarchical-grid' ;
13+ import { IgxPivotGridMultipleRowComponent , IgxPivotGridTestComplexHierarchyComponent } from '../../../../../test-utils/pivot-grid-samples.spec' ;
14+ import { IgxPivotGridComponent } from 'igniteui-angular/grids/pivot-grid' ;
15+ import { PivotRowLayoutType } from 'igniteui-angular/grids/core' ;
1316
1417describe ( 'PDF Grid Exporter' , ( ) => {
1518 let exporter : IgxPdfExporterService ;
@@ -19,7 +22,9 @@ describe('PDF Grid Exporter', () => {
1922 TestBed . configureTestingModule ( {
2023 imports : [
2124 NoopAnimationsModule ,
22- GridIDNameJobTitleComponent
25+ GridIDNameJobTitleComponent ,
26+ IgxPivotGridMultipleRowComponent ,
27+ IgxPivotGridTestComplexHierarchyComponent
2328 ]
2429 } ) . compileComponents ( ) ;
2530 } ) ) ;
@@ -388,4 +393,153 @@ describe('PDF Grid Exporter', () => {
388393 options . pageSize = 'a5' ;
389394 exporter . export ( grid , options ) ;
390395 } ) ;
396+
397+ describe ( 'Pivot Grid PDF Export' , ( ) => {
398+ let pivotGrid : IgxPivotGridComponent ;
399+
400+ // Helper function to wait for async operations
401+ const wait = ( ms : number ) => new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
402+
403+ it ( 'should export basic pivot grid' , async ( done ) => {
404+ const fix = TestBed . createComponent ( IgxPivotGridMultipleRowComponent ) ;
405+ fix . detectChanges ( ) ;
406+ await wait ( 300 ) ;
407+
408+ pivotGrid = fix . componentInstance . pivotGrid ;
409+
410+ exporter . exportEnded . pipe ( first ( ) ) . subscribe ( ( ) => {
411+ expect ( ExportUtilities . saveBlobToFile ) . toHaveBeenCalledTimes ( 1 ) ;
412+ done ( ) ;
413+ } ) ;
414+
415+ exporter . export ( pivotGrid , options ) ;
416+ } ) ;
417+
418+ it ( 'should export pivot grid with row headers' , async ( done ) => {
419+ const fix = TestBed . createComponent ( IgxPivotGridMultipleRowComponent ) ;
420+ fix . detectChanges ( ) ;
421+
422+ pivotGrid = fix . componentInstance . pivotGrid ;
423+ pivotGrid . pivotUI . showRowHeaders = true ;
424+ fix . detectChanges ( ) ;
425+ await wait ( 300 ) ;
426+
427+ exporter . exportEnded . pipe ( first ( ) ) . subscribe ( ( ) => {
428+ expect ( ExportUtilities . saveBlobToFile ) . toHaveBeenCalledTimes ( 1 ) ;
429+ done ( ) ;
430+ } ) ;
431+
432+ exporter . export ( pivotGrid , options ) ;
433+ } ) ;
434+
435+ it ( 'should export pivot grid with horizontal row layout' , async ( done ) => {
436+ const fix = TestBed . createComponent ( IgxPivotGridMultipleRowComponent ) ;
437+ fix . detectChanges ( ) ;
438+
439+ pivotGrid = fix . componentInstance . pivotGrid ;
440+ pivotGrid . pivotUI . showRowHeaders = true ;
441+ pivotGrid . pivotUI . rowLayout = PivotRowLayoutType . Horizontal ;
442+ pivotGrid . pivotConfiguration . rows = [ {
443+ memberName : 'ProductCategory' ,
444+ memberFunction : ( data ) => data . ProductCategory ,
445+ enabled : true ,
446+ childLevel : {
447+ memberName : 'Country' ,
448+ enabled : true ,
449+ childLevel : {
450+ memberName : 'Date' ,
451+ enabled : true
452+ }
453+ }
454+ } ] ;
455+ fix . detectChanges ( ) ;
456+ await wait ( 300 ) ;
457+
458+ exporter . exportEnded . pipe ( first ( ) ) . subscribe ( ( ) => {
459+ expect ( ExportUtilities . saveBlobToFile ) . toHaveBeenCalledTimes ( 1 ) ;
460+ done ( ) ;
461+ } ) ;
462+
463+ exporter . export ( pivotGrid , options ) ;
464+ } ) ;
465+
466+ it ( 'should export hierarchical pivot grid' , async ( done ) => {
467+ const fix = TestBed . createComponent ( IgxPivotGridTestComplexHierarchyComponent ) ;
468+ fix . detectChanges ( ) ;
469+ await wait ( 300 ) ;
470+
471+ pivotGrid = fix . componentInstance . pivotGrid ;
472+
473+ exporter . exportEnded . pipe ( first ( ) ) . subscribe ( ( ) => {
474+ expect ( ExportUtilities . saveBlobToFile ) . toHaveBeenCalledTimes ( 1 ) ;
475+ done ( ) ;
476+ } ) ;
477+
478+ exporter . export ( pivotGrid , options ) ;
479+ } ) ;
480+
481+ it ( 'should export pivot grid with custom page size' , async ( done ) => {
482+ const fix = TestBed . createComponent ( IgxPivotGridMultipleRowComponent ) ;
483+ fix . detectChanges ( ) ;
484+ await wait ( 300 ) ;
485+
486+ pivotGrid = fix . componentInstance . pivotGrid ;
487+ options . pageSize = 'letter' ;
488+
489+ exporter . exportEnded . pipe ( first ( ) ) . subscribe ( ( ) => {
490+ expect ( ExportUtilities . saveBlobToFile ) . toHaveBeenCalledTimes ( 1 ) ;
491+ done ( ) ;
492+ } ) ;
493+
494+ exporter . export ( pivotGrid , options ) ;
495+ } ) ;
496+
497+ it ( 'should export pivot grid with landscape orientation' , async ( done ) => {
498+ const fix = TestBed . createComponent ( IgxPivotGridMultipleRowComponent ) ;
499+ fix . detectChanges ( ) ;
500+ await wait ( 300 ) ;
501+
502+ pivotGrid = fix . componentInstance . pivotGrid ;
503+ options . pageOrientation = 'landscape' ;
504+
505+ exporter . exportEnded . pipe ( first ( ) ) . subscribe ( ( ) => {
506+ expect ( ExportUtilities . saveBlobToFile ) . toHaveBeenCalledTimes ( 1 ) ;
507+ done ( ) ;
508+ } ) ;
509+
510+ exporter . export ( pivotGrid , options ) ;
511+ } ) ;
512+
513+ it ( 'should export pivot grid without table borders' , async ( done ) => {
514+ const fix = TestBed . createComponent ( IgxPivotGridMultipleRowComponent ) ;
515+ fix . detectChanges ( ) ;
516+ await wait ( 300 ) ;
517+
518+ pivotGrid = fix . componentInstance . pivotGrid ;
519+ options . showTableBorders = false ;
520+
521+ exporter . exportEnded . pipe ( first ( ) ) . subscribe ( ( ) => {
522+ expect ( ExportUtilities . saveBlobToFile ) . toHaveBeenCalledTimes ( 1 ) ;
523+ done ( ) ;
524+ } ) ;
525+
526+ exporter . export ( pivotGrid , options ) ;
527+ } ) ;
528+
529+ it ( 'should export pivot grid with custom font size' , async ( done ) => {
530+ const fix = TestBed . createComponent ( IgxPivotGridMultipleRowComponent ) ;
531+ fix . detectChanges ( ) ;
532+ await wait ( 300 ) ;
533+
534+ pivotGrid = fix . componentInstance . pivotGrid ;
535+ options . fontSize = 14 ;
536+
537+ exporter . exportEnded . pipe ( first ( ) ) . subscribe ( ( ) => {
538+ expect ( ExportUtilities . saveBlobToFile ) . toHaveBeenCalledTimes ( 1 ) ;
539+ done ( ) ;
540+ } ) ;
541+
542+ exporter . export ( pivotGrid , options ) ;
543+ } ) ;
544+ } ) ;
391545} ) ;
0 commit comments