1
1
describe ( 'ui.grid.moveColumns' , function ( ) {
2
2
3
- var scope , element , timeout , gridUtil , document ;
3
+ var scope , element , timeout , gridUtil , document , uiGridConstants ;
4
4
5
5
var data = [
6
6
{ "name" : "Ethel Price" , "gender" : "female" , "age" : 25 , "company" : "Enersol" , phone : '111' } ,
@@ -11,14 +11,14 @@ describe('ui.grid.moveColumns', function () {
11
11
12
12
beforeEach ( module ( 'ui.grid.moveColumns' ) ) ;
13
13
14
- beforeEach ( inject ( function ( _$compile_ , $rootScope , $timeout , _gridUtil_ , $document ) {
14
+ beforeEach ( inject ( function ( _$compile_ , $rootScope , $timeout , _gridUtil_ , $document , _uiGridConstants_ ) {
15
15
16
16
var $compile = _$compile_ ;
17
17
scope = $rootScope ;
18
18
timeout = $timeout ;
19
19
gridUtil = _gridUtil_ ;
20
20
document = $document ;
21
-
21
+ uiGridConstants = _uiGridConstants_ ;
22
22
23
23
scope . gridOptions = { } ;
24
24
scope . gridOptions . data = data ;
@@ -74,6 +74,21 @@ describe('ui.grid.moveColumns', function () {
74
74
expect ( scope . grid . columns [ 4 ] . name ) . toBe ( 'gender' ) ;
75
75
} ) ;
76
76
77
+ it ( 'expect moveColumn() to persist after adding additional column' , function ( ) {
78
+ scope . gridApi . colMovable . moveColumn ( 0 , 1 ) ;
79
+ scope . gridOptions . columnDefs . push ( { field : 'name' , displayName : 'name2' , width : 200 } ) ;
80
+ scope . gridApi . core . notifyDataChange ( uiGridConstants . COLUMN ) ;
81
+ timeout . flush ( ) ;
82
+ scope . $digest ( ) ;
83
+
84
+ expect ( scope . grid . columns [ 0 ] . name ) . toBe ( 'gender' ) ;
85
+ expect ( scope . grid . columns [ 1 ] . name ) . toBe ( 'name' ) ;
86
+ expect ( scope . grid . columns [ 2 ] . name ) . toBe ( 'age' ) ;
87
+ expect ( scope . grid . columns [ 3 ] . name ) . toBe ( 'company' ) ;
88
+ expect ( scope . grid . columns [ 4 ] . name ) . toBe ( 'phone' ) ;
89
+ expect ( scope . grid . columns [ 5 ] . displayName ) . toBe ( 'name2' ) ;
90
+ } ) ;
91
+
77
92
it ( 'expect moveColumn() to not change position of columns if enableColumnMoving is false' , function ( ) {
78
93
scope . gridApi . colMovable . moveColumn ( 2 , 1 ) ;
79
94
expect ( scope . grid . columns [ 0 ] . name ) . toBe ( 'name' ) ;
0 commit comments