@@ -37,8 +37,10 @@ describe('stSort Directive', function () {
37
37
beforeEach ( inject ( function ( $compile , $rootScope , stConfig ) {
38
38
var oldAscentClass = stConfig . sort . ascentClass ;
39
39
var oldDescentClass = stConfig . sort . descentClass ;
40
+ var oldSkipNatural = stConfig . sort . skipNatural ;
40
41
stConfig . sort . ascentClass = 'custom-ascent' ;
41
42
stConfig . sort . descentClass = 'custom-descent' ;
43
+ stConfig . sort . skipNatural = true ;
42
44
43
45
rootScope = $rootScope ;
44
46
scope = $rootScope . $new ( ) ;
@@ -81,6 +83,7 @@ describe('stSort Directive', function () {
81
83
82
84
stConfig . sort . ascentClass = oldAscentClass ;
83
85
stConfig . sort . descentClass = oldDescentClass ;
86
+ stConfig . sort . skipNatural = oldSkipNatural ;
84
87
} ) ) ;
85
88
86
89
it ( 'should customize classes for sorting' , function ( ) {
@@ -89,6 +92,26 @@ describe('stSort Directive', function () {
89
92
expect ( hasClass ( ths [ 1 ] , 'custom-ascent' ) ) . toBe ( true ) ;
90
93
expect ( hasClass ( ths [ 1 ] , 'custom-descent' ) ) . toBe ( false ) ;
91
94
} ) ;
95
+
96
+ it ( 'should skip natural order' , function ( ) {
97
+ var ths = element . find ( 'th' ) ;
98
+ var th1 = angular . element ( ths [ 1 ] ) ;
99
+ th1 . triggerHandler ( 'click' ) ;
100
+ th1 . triggerHandler ( 'click' ) ;
101
+ th1 . triggerHandler ( 'click' ) ;
102
+ scope . $apply ( ) ;
103
+ var actual = trToModel ( element . find ( 'tr.test-row' ) ) ;
104
+ expect ( hasClass ( ths [ 1 ] , 'custom-ascent' ) ) . toBe ( true ) ;
105
+ expect ( hasClass ( ths [ 1 ] , 'custom-descent' ) ) . toBe ( false ) ;
106
+ expect ( actual ) . toEqual ( [
107
+ { name : 'Faivre' , firstname : 'Blandine' , age : 44 } ,
108
+ { name : 'Leponge' , firstname : 'Bob' , age : 22 } ,
109
+ { name : 'Francoise' , firstname : 'Frere' , age : 99 } ,
110
+ { name : 'Renard' , firstname : 'Laurent' , age : 66 } ,
111
+ { name : 'Renard' , firstname : 'Olivier' , age : 33 }
112
+ ] ) ;
113
+ } ) ;
114
+
92
115
} ) ;
93
116
94
117
describe ( 'normal stConfig' , function ( ) {
@@ -387,4 +410,4 @@ describe('stSort Directive', function () {
387
410
} ) ;
388
411
389
412
390
- } ) ;
413
+ } ) ;
0 commit comments