@@ -26,10 +26,15 @@ import { configureTestSuite } from '../../test-utils/configure-suite';
26
26
import { IgxTreeGridPrimaryForeignKeyComponent } from '../../test-utils/tree-grid-components.spec' ;
27
27
import { IgxTreeGridModule , IgxTreeGridComponent } from '../../grids/tree-grid/public_api' ;
28
28
import { IgxNumberFilteringOperand } from '../../data-operations/filtering-condition' ;
29
- import { wait } from '../../test-utils/ui-interactions.spec' ;
29
+ import { UIInteractions , wait } from '../../test-utils/ui-interactions.spec' ;
30
30
import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
31
31
import { FilteringExpressionsTree } from '../../data-operations/filtering-expressions-tree' ;
32
32
import { FilteringLogic } from '../../data-operations/filtering-expression.interface' ;
33
+ import { IgxHierarchicalGridExportComponent } from '../../test-utils/hierarchical-grid-components.spec' ;
34
+ import { IgxHierarchicalGridModule ,
35
+ IgxHierarchicalGridComponent ,
36
+ } from '../../grids/hierarchical-grid/public_api' ;
37
+ import { IgxHierarchicalRowComponent } from '../../grids/hierarchical-grid/hierarchical-row.component' ;
33
38
34
39
describe ( 'Excel Exporter' , ( ) => {
35
40
configureTestSuite ( ) ;
@@ -47,9 +52,10 @@ describe('Excel Exporter', () => {
47
52
GridWithEmptyColumnsComponent ,
48
53
GridIDNameJobTitleHireDataPerformanceComponent ,
49
54
GridHireDateComponent ,
50
- GridExportGroupedDataComponent
55
+ GridExportGroupedDataComponent ,
56
+ IgxHierarchicalGridExportComponent
51
57
] ,
52
- imports : [ IgxGridModule , IgxTreeGridModule , NoopAnimationsModule ]
58
+ imports : [ IgxGridModule , IgxTreeGridModule , IgxHierarchicalGridModule , NoopAnimationsModule ]
53
59
} ) . compileComponents ( ) ;
54
60
} ) ) ;
55
61
@@ -140,7 +146,6 @@ describe('Excel Exporter', () => {
140
146
await wait ( ) ;
141
147
142
148
const grid = fix . componentInstance . grid ;
143
- options . ignoreColumnsOrder = true ;
144
149
options . ignoreColumnsVisibility = false ;
145
150
146
151
expect ( grid . visibleColumns . length ) . toEqual ( 3 , 'Invalid number of visible columns!' ) ;
@@ -632,6 +637,101 @@ describe('Excel Exporter', () => {
632
637
} ) ;
633
638
} ) ;
634
639
640
+ describe ( '' , ( ) => {
641
+ let fix ;
642
+ let hGrid : IgxHierarchicalGridComponent ;
643
+
644
+ beforeEach ( waitForAsync ( ( ) => {
645
+ options = createExportOptions ( 'HierarchicalGridExcelExport' ) ;
646
+ fix = TestBed . createComponent ( IgxHierarchicalGridExportComponent ) ;
647
+ fix . detectChanges ( ) ;
648
+
649
+ hGrid = fix . componentInstance . hGrid ;
650
+ } ) ) ;
651
+
652
+ it ( 'should export hierarchical grid' , async ( ) => {
653
+ await exportAndVerify ( hGrid , options , actualData . exportHierarchicalData ) ;
654
+ } ) ;
655
+
656
+ it ( 'should export hierarchical grid respecting options width.' , async ( ) => {
657
+ options = createExportOptions ( 'HierarchicalGridExcelExport' , 50 ) ;
658
+ await exportAndVerify ( hGrid , options , actualData . exportHierarchicalDataWithColumnWidth ) ;
659
+ } ) ;
660
+
661
+ it ( 'should export sorted hierarchical grid data' , async ( ) => {
662
+ hGrid . sort ( { fieldName : 'GrammyNominations' , dir : SortingDirection . Desc } ) ;
663
+
664
+ fix . detectChanges ( ) ;
665
+
666
+ await exportAndVerify ( hGrid , options , actualData . exportSortedHierarchicalData ) ;
667
+ } ) ;
668
+
669
+ it ( 'should export hierarchical grid data with ignored sorting' , async ( ) => {
670
+ hGrid . sort ( { fieldName : 'GrammyNominations' , dir : SortingDirection . Desc } ) ;
671
+
672
+ options . ignoreSorting = true ;
673
+ fix . detectChanges ( ) ;
674
+
675
+ await exportAndVerify ( hGrid , options , actualData . exportHierarchicalData ) ;
676
+ } ) ;
677
+
678
+ it ( 'should export filtered hierarchical grid data' , async ( ) => {
679
+ hGrid . filter ( 'Debut' , '2009' , IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) , true ) ;
680
+ fix . detectChanges ( ) ;
681
+
682
+ await exportAndVerify ( hGrid , options , actualData . exportFilteredHierarchicalData ) ;
683
+ } ) ;
684
+
685
+ it ( 'should export hierarchical grid data with ignored filtering' , async ( ) => {
686
+ hGrid . filter ( 'Debut' , '2009' , IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) , true ) ;
687
+ fix . detectChanges ( ) ;
688
+
689
+ options . ignoreFiltering = true ;
690
+
691
+ await exportAndVerify ( hGrid , options , actualData . exportHierarchicalData ) ;
692
+ } ) ;
693
+
694
+ it ( 'should export hierarchical grid with expanded rows.' , async ( ) => {
695
+ const firstRow = hGrid . hgridAPI . get_row_by_index ( 0 ) as IgxHierarchicalRowComponent ;
696
+ const secondRow = hGrid . hgridAPI . get_row_by_index ( 1 ) as IgxHierarchicalRowComponent ;
697
+
698
+ UIInteractions . simulateClickAndSelectEvent ( firstRow . expander ) ;
699
+ fix . detectChanges ( ) ;
700
+ expect ( firstRow . expanded ) . toBe ( true ) ;
701
+
702
+ let childGrids = hGrid . hgridAPI . getChildGrids ( false ) ;
703
+
704
+ const firstChildGrid = childGrids [ 0 ] ;
705
+ const firstChildRow = firstChildGrid . hgridAPI . get_row_by_index ( 2 ) as IgxHierarchicalRowComponent ;
706
+
707
+ UIInteractions . simulateClickAndSelectEvent ( firstChildRow . expander ) ;
708
+ fix . detectChanges ( ) ;
709
+ expect ( firstChildRow . expanded ) . toBe ( true ) ;
710
+
711
+ const secondChildGrid = childGrids [ 1 ] ;
712
+ const secondChildRow = secondChildGrid . hgridAPI . get_row_by_index ( 0 ) as IgxHierarchicalRowComponent ;
713
+
714
+ UIInteractions . simulateClickAndSelectEvent ( secondChildRow . expander ) ;
715
+ fix . detectChanges ( ) ;
716
+ expect ( secondChildRow . expanded ) . toBe ( true ) ;
717
+
718
+ UIInteractions . simulateClickAndSelectEvent ( secondRow . expander ) ;
719
+ fix . detectChanges ( ) ;
720
+ expect ( secondRow . expanded ) . toBe ( true ) ;
721
+
722
+ childGrids = hGrid . hgridAPI . getChildGrids ( false ) ;
723
+
724
+ const thirdChildGrid = childGrids [ 3 ] ;
725
+ const thirdChildRow = thirdChildGrid . hgridAPI . get_row_by_index ( 0 ) as IgxHierarchicalRowComponent ;
726
+
727
+ UIInteractions . simulateClickAndSelectEvent ( thirdChildRow . expander ) ;
728
+ fix . detectChanges ( ) ;
729
+ expect ( thirdChildRow . expanded ) . toBe ( true ) ;
730
+
731
+ await exportAndVerify ( hGrid , options , actualData . exportHierarchicalDataWithExpandedRows ) ;
732
+ } ) ;
733
+ } ) ;
734
+
635
735
describe ( '' , ( ) => {
636
736
let fix ;
637
737
let treeGrid : IgxTreeGridComponent ;
@@ -855,9 +955,10 @@ describe('Excel Exporter', () => {
855
955
} ;
856
956
857
957
const exportAndVerify = async ( component , exportOptions , expectedData ) => {
958
+ const isHGrid = component instanceof IgxHierarchicalGridComponent ;
858
959
const wrapper = await getExportedData ( component , exportOptions ) ;
859
- await wrapper . verifyStructure ( ) ;
860
- await wrapper . verifyDataFilesContent ( expectedData ) ;
960
+ await wrapper . verifyStructure ( isHGrid ) ;
961
+ await wrapper . verifyDataFilesContent ( expectedData , '' , isHGrid ) ;
861
962
} ;
862
963
} ) ;
863
964
0 commit comments