@@ -117,6 +117,72 @@ describe('$route', function() {
117
117
} ) ;
118
118
} ) ;
119
119
120
+
121
+ it ( 'should route and fire change event correctly whenever the case insensitive flag is utilized' , function ( ) {
122
+ var log = '' ,
123
+ lastRoute ,
124
+ nextRoute ;
125
+
126
+ module ( function ( $routeProvider ) {
127
+ $routeProvider . when ( '/Book1/:book/Chapter/:chapter/*highlight/edit' ,
128
+ { controller : noop , templateUrl : 'Chapter.html' , caseInsensitiveMatch : true } ) ;
129
+ $routeProvider . when ( '/Book2/:book/*highlight/Chapter/:chapter' ,
130
+ { controller : noop , templateUrl : 'Chapter.html' } ) ;
131
+ $routeProvider . when ( '/Blank' , { } ) ;
132
+ } ) ;
133
+ inject ( function ( $route , $location , $rootScope ) {
134
+ $rootScope . $on ( '$routeChangeStart' , function ( event , next , current ) {
135
+ log += 'before();' ;
136
+ expect ( current ) . toBe ( $route . current ) ;
137
+ lastRoute = current ;
138
+ nextRoute = next ;
139
+ } ) ;
140
+ $rootScope . $on ( '$routeChangeSuccess' , function ( event , current , last ) {
141
+ log += 'after();' ;
142
+ expect ( current ) . toBe ( $route . current ) ;
143
+ expect ( lastRoute ) . toBe ( last ) ;
144
+ expect ( nextRoute ) . toBe ( current ) ;
145
+ } ) ;
146
+
147
+ $location . path ( '/Book1/Moby/Chapter/Intro/one/edit' ) . search ( 'p=123' ) ;
148
+ $rootScope . $digest ( ) ;
149
+ $httpBackend . flush ( ) ;
150
+ expect ( log ) . toEqual ( 'before();after();' ) ;
151
+ expect ( $route . current . params ) . toEqual ( { book :'Moby' , chapter :'Intro' , highlight :'one' , p :'123' } ) ;
152
+
153
+ log = '' ;
154
+ $location . path ( '/BOOK1/Moby/CHAPTER/Intro/one/EDIT' ) . search ( 'p=123' ) ;
155
+ $rootScope . $digest ( ) ;
156
+ expect ( log ) . toEqual ( 'before();after();' ) ;
157
+ expect ( $route . current . params ) . toEqual ( { book :'Moby' , chapter :'Intro' , highlight :'one' , p :'123' } ) ;
158
+
159
+ log = '' ;
160
+ $location . path ( '/Blank' ) . search ( 'ignore' ) ;
161
+ $rootScope . $digest ( ) ;
162
+ expect ( log ) . toEqual ( 'before();after();' ) ;
163
+ expect ( $route . current . params ) . toEqual ( { ignore :true } ) ;
164
+
165
+ log = '' ;
166
+ $location . path ( '/BLANK' ) ;
167
+ $rootScope . $digest ( ) ;
168
+ expect ( log ) . toEqual ( 'before();after();' ) ;
169
+ expect ( $route . current ) . toEqual ( null ) ;
170
+
171
+ log = '' ;
172
+ $location . path ( '/Book2/Moby/one/two/Chapter/Intro' ) . search ( 'p=123' ) ;
173
+ $rootScope . $digest ( ) ;
174
+ expect ( log ) . toEqual ( 'before();after();' ) ;
175
+ expect ( $route . current . params ) . toEqual ( { book :'Moby' , chapter :'Intro' , highlight :'one/two' , p :'123' } ) ;
176
+
177
+ log = '' ;
178
+ $location . path ( '/BOOK2/Moby/one/two/CHAPTER/Intro' ) . search ( 'p=123' ) ;
179
+ $rootScope . $digest ( ) ;
180
+ expect ( log ) . toEqual ( 'before();after();' ) ;
181
+ expect ( $route . current ) . toEqual ( null ) ;
182
+ } ) ;
183
+ } ) ;
184
+
185
+
120
186
it ( 'should not change route when location is canceled' , function ( ) {
121
187
module ( function ( $routeProvider ) {
122
188
$routeProvider . when ( '/somePath' , { template : 'some path' } ) ;
0 commit comments