@@ -102,8 +102,12 @@ describe('ui.grid.grouping uiGridGroupingService', function () {
102
102
103
103
104
104
describe ( 'groupRows' , function ( ) {
105
+ beforeEach ( function ( ) {
106
+ spyOn ( gridClassFactory , 'rowTemplateAssigner' ) . and . callFake ( function ( ) { } ) ;
107
+ } ) ;
108
+
105
109
it ( 'group by col0 then col1' , function ( ) {
106
- spyOn ( gridClassFactory , 'rowTemplateAssigner' ) . andCallFake ( function ( ) { } ) ;
110
+
107
111
grid . columns [ 0 ] . grouping = { groupPriority : 1 } ;
108
112
grid . columns [ 1 ] . grouping = { groupPriority : 2 } ;
109
113
@@ -112,7 +116,6 @@ describe('ui.grid.grouping uiGridGroupingService', function () {
112
116
} ) ;
113
117
114
118
it ( 'group by col4 (type date with nulls)' , function ( ) {
115
- spyOn ( gridClassFactory , 'rowTemplateAssigner' ) . andCallFake ( function ( ) { } ) ;
116
119
grid . columns [ 4 ] . grouping = { groupPriority : 1 } ;
117
120
118
121
uiGridGroupingService . tidyPriorities ( grid ) ;
@@ -482,49 +485,55 @@ describe('ui.grid.grouping uiGridGroupingService', function () {
482
485
} ) ;
483
486
} ) ;
484
487
485
- it ( 'sorts' , function ( ) {
486
- grid . grouping . groupingHeaderCache = {
487
- male : {
488
- row : { treeNode : { state : 'collapsed' } } ,
489
- children : {
490
- 22 : { row : { treeNode : { state : 'expanded' } } , children : { } } ,
491
- 39 : { row : { treeNode : { state : 'collapsed' } } , children : { } }
488
+
489
+ describe ( 'sorts' , function ( ) {
490
+ beforeEach ( function ( ) {
491
+ spyOn ( grid . api . core . raise , 'sortChanged' ) . and . callThrough ( ) ;
492
+ } ) ;
493
+
494
+ it ( '' , function ( ) {
495
+ grid . grouping . groupingHeaderCache = {
496
+ male : {
497
+ row : { treeNode : { state : 'collapsed' } } ,
498
+ children : {
499
+ 22 : { row : { treeNode : { state : 'expanded' } } , children : { } } ,
500
+ 39 : { row : { treeNode : { state : 'collapsed' } } , children : { } }
501
+ }
502
+ } ,
503
+ female : {
504
+ row : { treeNode : { state : 'expanded' } } ,
505
+ children : {
506
+ 23 : { row : { treeNode : { state : 'collapsed' } } , children : { } } ,
507
+ 38 : { row : { treeNode : { state : 'expanded' } } , children : { } }
508
+ }
492
509
}
493
- } ,
494
- female : {
495
- row : { treeNode : { state : 'expanded' } } ,
496
- children : {
497
- 23 : { row : { treeNode : { state : 'collapsed' } } , children : { } } ,
498
- 38 : { row : { treeNode : { state : 'expanded' } } , children : { } }
510
+ } ;
511
+
512
+
513
+ grid . api . grouping . setGrouping ( {
514
+ grouping : [
515
+ { field : 'col3' , colName : 'col3' , groupPriority : 0 } ,
516
+ { field : 'col2' , colName : 'col2' , groupPriority : 1 }
517
+ ] ,
518
+ aggregations : [
519
+ { field : 'col1' , colName : 'col1' , aggregation : { type : uiGridGroupingConstants . aggregation . COUNT } }
520
+ ] ,
521
+ rowExpandedStates : {
522
+ male : { state : 'expanded' , children : {
523
+ 22 : { state : 'collapsed' } ,
524
+ 38 : { state : 'expanded' }
525
+ } } ,
526
+ female : { state : 'expanded' , children : {
527
+ 23 : { state : 'expanded' } ,
528
+ 39 : { state : 'collapsed' }
529
+ } }
499
530
}
500
- }
501
- } ;
531
+ } ) ;
502
532
503
- spyOn ( grid . api . core . raise , 'sortChanged' ) . andCallThrough ( ) ;
504
-
505
- grid . api . grouping . setGrouping ( {
506
- grouping : [
507
- { field : 'col3' , colName : 'col3' , groupPriority : 0 } ,
508
- { field : 'col2' , colName : 'col2' , groupPriority : 1 }
509
- ] ,
510
- aggregations : [
511
- { field : 'col1' , colName : 'col1' , aggregation : { type : uiGridGroupingConstants . aggregation . COUNT } }
512
- ] ,
513
- rowExpandedStates : {
514
- male : { state : 'expanded' , children : {
515
- 22 : { state : 'collapsed' } ,
516
- 38 : { state : 'expanded' }
517
- } } ,
518
- female : { state : 'expanded' , children : {
519
- 23 : { state : 'expanded' } ,
520
- 39 : { state : 'collapsed' }
521
- } }
522
- }
533
+ // Should call sort change twice because we are grouping by two columns
534
+ expect ( grid . api . core . raise . sortChanged . calls . count ( ) ) . toEqual ( 2 ) ;
523
535
} ) ;
524
536
525
- // Should call sort change twice because we are grouping by two columns
526
- expect ( grid . api . core . raise . sortChanged . calls . length ) . toEqual ( 2 ) ;
527
-
528
537
} ) ;
529
538
530
539
} ) ;
@@ -572,7 +581,9 @@ describe('ui.grid.grouping uiGridGroupingService', function () {
572
581
573
582
describe ( 'insertGroupHeader' , function ( ) {
574
583
it ( 'inserts a header in the middle' , function ( ) {
575
- spyOn ( gridClassFactory , 'rowTemplateAssigner' ) . andCallFake ( function ( ) { } ) ;
584
+ var rowTemplateSpy = jasmine . createSpy ( 'rowTemplateSpy' ) ;
585
+ rowTemplateSpy . and . callFake ( function ( ) { } ) ;
586
+ rowTemplateSpy ( gridClassFactory , 'rowTemplateAssigner' ) ;
576
587
var headerRow1 = new GridRow ( { } , null , grid ) ;
577
588
var headerRow2 = new GridRow ( { } , null , grid ) ;
578
589
var headerRow3 = new GridRow ( { } , null , grid ) ;
0 commit comments