@@ -222,7 +222,7 @@ describe('state helpers', function() {
222222
223223describe ( 'state' , function ( ) {
224224
225- var $injector , stateProvider , locationProvider , templateParams , template , ctrlName ;
225+ var $injector , $ stateProvider, locationProvider , templateParams , template , ctrlName ;
226226
227227 beforeEach ( module ( 'ui.router' , function ( $locationProvider ) {
228228 locationProvider = $locationProvider ;
@@ -248,24 +248,18 @@ describe('state', function () {
248248 HH = { parent : H , template : "hh" } ,
249249 HHH = { parent : HH , data : { propA : 'overriddenA' , propC : 'propC' } , template : "hhh" } ,
250250 RS = { url : '^/search?term' , reloadOnSearch : false , template : "rs" } ,
251- dynamicstate = {
252- url : '^/dynstate/:path/:pathDyn?search&searchDyn' , params : {
253- pathDyn : { dynamic : true } ,
254- searchDyn : { dynamic : true }
255- } , template : "dynamicstate"
256- } ,
257251 OPT = { url : '/opt/:param' , params : { param : "100" } , template : "opt" } ,
258252 OPT2 = { url : '/opt2/:param2/:param3' , params : { param3 : "300" , param4 : "400" } , template : "opt2" } ,
259253 ISS2101 = { params : { bar : { squash : false , value : 'qux' } } , url : '/2101/{bar:string}' } ,
260254 URLLESS = { url : '/urllessparams' , params : { myparam : { type : 'int' } } } ,
261255 AppInjectable = { } ;
262256
263- beforeEach ( module ( function ( $stateProvider , $provide ) {
257+ beforeEach ( module ( function ( _$stateProvider_ , $provide ) {
264258 angular . forEach ( [ A , B , C , D , DD , E , H , HH , HHH ] , function ( state ) {
265259 state . onEnter = callbackLogger ( state , 'onEnter' ) ;
266260 state . onExit = callbackLogger ( state , 'onExit' ) ;
267261 } ) ;
268- stateProvider = $stateProvider ;
262+ $ stateProvider = _$stateProvider_ ;
269263
270264 $stateProvider
271265 . state ( 'A' , A )
@@ -280,7 +274,6 @@ describe('state', function () {
280274 . state ( 'HH' , HH )
281275 . state ( 'HHH' , HHH )
282276 . state ( 'RS' , RS )
283- . state ( 'dynamicstate' , dynamicstate )
284277 . state ( 'OPT' , OPT )
285278 . state ( 'OPT.OPT2' , OPT2 )
286279 . state ( 'ISS2101' , ISS2101 )
@@ -409,10 +402,10 @@ describe('state', function () {
409402 describe ( 'provider' , function ( ) {
410403 it ( 'should ignore Object properties when registering states' , function ( ) {
411404 expect ( function ( ) {
412- stateProvider . state ( 'toString' , { url : "/to-string" } ) ;
405+ $ stateProvider. state ( 'toString' , { url : "/to-string" } ) ;
413406 } ) . not . toThrow ( ) ;
414407 expect ( function ( ) {
415- stateProvider . state ( 'watch' , { url : "/watch" } ) ;
408+ $ stateProvider. state ( 'watch' , { url : "/watch" } ) ;
416409 } ) . not . toThrow ( ) ;
417410 } ) ;
418411 } ) ;
@@ -446,17 +439,6 @@ describe('state', function () {
446439 } ) ) ;
447440
448441 describe ( "(dynamic params)" , function ( ) {
449- var stateChanged ;
450-
451- beforeEach ( inject ( function ( _$rootScope_ , _$state_ , _$stateParams_ , _$transitions_ , _$q_ , _$location_ ) {
452- $transitions . onStart ( { } , function ( ) {
453- stateChanged = true ;
454- } ) ;
455-
456- $q . flush ( ) ;
457- } ) ) ;
458-
459-
460442 it ( 'resolves a fully dynamic $state.go() with the current state' , function ( ) {
461443 initStateTo ( RS ) ;
462444 var destState , promise = $state . go ( "." , { term : "hello" } ) ;
@@ -480,7 +462,27 @@ describe('state', function () {
480462 } ) ;
481463
482464 describe ( "" , function ( ) {
465+ var stateChanged , dynamicstate ;
466+
483467 beforeEach ( function ( ) {
468+ dynamicstate = {
469+ name : 'dynamicstate' ,
470+ url : '^/dynstate/:path/:pathDyn?search&searchDyn' ,
471+ params : {
472+ pathDyn : { dynamic : true } ,
473+ searchDyn : { dynamic : true }
474+ } ,
475+ template : "dynamicstate" ,
476+ controller : function ( $stateParams ) {
477+ $scope . $watch ( $stateParams . searchDyn ) ;
478+ }
479+ }
480+ $stateProvider . state ( dynamicstate ) ;
481+
482+ $transitions . onSuccess ( { } , function ( ) {
483+ stateChanged = true ;
484+ } ) ;
485+
484486 initStateTo ( dynamicstate , { path : 'pathfoo' , pathDyn : 'pathbar' , search : 'searchfoo' , searchDyn : 'searchbar' } ) ;
485487 expect ( stateChanged ) . toBeTruthy ( ) ;
486488 expect ( obj ( $stateParams ) ) . toEqual ( { path : 'pathfoo' , pathDyn : 'pathbar' , search : 'searchfoo' , searchDyn : 'searchbar' } ) ;
@@ -489,28 +491,28 @@ describe('state', function () {
489491 } ) ;
490492
491493 it ( 'triggers state change for non-dynamic search params' , function ( ) {
492- $state . go ( dynamicstate , { search : 'somethingelse' } ) ;
494+ $state . go ( ' dynamicstate' , { search : 'somethingelse' } ) ;
493495 $q . flush ( ) ;
494496 expect ( stateChanged ) . toBeTruthy ( ) ;
495497 expect ( obj ( $stateParams ) ) . toEqual ( { path : 'pathfoo' , pathDyn : 'pathbar' , search : 'somethingelse' , searchDyn : 'searchbar' } ) ;
496498 } ) ;
497499
498500 it ( 'does not trigger state change for dynamic search params' , function ( ) {
499- $state . go ( dynamicstate , { searchDyn : 'somethingelse' } ) ;
501+ $state . go ( ' dynamicstate' , { searchDyn : 'somethingelse' } ) ;
500502 $q . flush ( ) ;
501503 expect ( stateChanged ) . toBeFalsy ( ) ;
502504 expect ( obj ( $stateParams ) ) . toEqual ( { path : 'pathfoo' , pathDyn : 'pathbar' , search : 'searchfoo' , searchDyn : 'somethingelse' } ) ;
503505 } ) ;
504506
505507 it ( 'triggers state change for non-dynamic path params' , function ( ) {
506- $state . go ( dynamicstate , { path : 'somethingelse' } ) ;
508+ $state . go ( ' dynamicstate' , { path : 'somethingelse' } ) ;
507509 $q . flush ( ) ;
508510 expect ( stateChanged ) . toBeTruthy ( ) ;
509511 expect ( obj ( $stateParams ) ) . toEqual ( { path : 'somethingelse' , pathDyn : 'pathbar' , search : 'searchfoo' , searchDyn : 'searchbar' } ) ;
510512 } ) ;
511513
512514 it ( 'does not trigger state change for dynamic path params' , function ( ) {
513- $state . go ( dynamicstate , { pathDyn : 'somethingelse' } ) ;
515+ $state . go ( ' dynamicstate' , { pathDyn : 'somethingelse' } ) ;
514516 $q . flush ( ) ;
515517 expect ( stateChanged ) . toBeFalsy ( ) ;
516518 expect ( obj ( $stateParams ) ) . toEqual ( { path : 'pathfoo' , pathDyn : 'somethingelse' , search : 'searchfoo' , searchDyn : 'searchbar' } ) ;
@@ -1127,7 +1129,7 @@ describe('state', function () {
11271129 var list = $state . get ( ) . sort ( function ( a , b ) { return ( a . name > b . name ) - ( b . name > a . name ) ; } ) ;
11281130 var names = [ '' , 'A' , 'B' , 'C' , 'D' , 'DD' , 'DDDD' , 'E' , 'F' , 'H' , 'HH' , 'HHH' , 'ISS2101' , 'OPT' , 'OPT.OPT2' , 'RS' , 'URLLESS' ,
11291131 'about' , 'about.person' , 'about.person.item' , 'about.sidebar' , 'about.sidebar.item' ,
1130- 'badParam' , 'badParam2' , 'dynamicTemplate' , 'dynamicstate' , ' first', 'home' , 'home.item' , 'home.redirect' ,
1132+ 'badParam' , 'badParam2' , 'dynamicTemplate' , 'first' , 'home' , 'home.item' , 'home.redirect' ,
11311133 'json' , 'logA' , 'logA.logB' , 'logA.logB.logC' , 'resolveFail' , 'resolveTimeout' ,
11321134 'root' , 'root.sub1' , 'root.sub2' , 'second' ] ;
11331135
@@ -1278,7 +1280,7 @@ describe('state', function () {
12781280 var $rootScope , $state , $compile ;
12791281 beforeEach ( function ( ) {
12801282
1281- stateProvider . state ( 'myState' , {
1283+ $ stateProvider. state ( 'myState' , {
12821284 template : 'myState' ,
12831285 url : '/my-state?:previous' ,
12841286 controller : function ( ) {
@@ -1350,7 +1352,7 @@ describe('state', function () {
13501352
13511353 describe ( "typed parameter handling" , function ( ) {
13521354 beforeEach ( function ( ) {
1353- stateProvider . state ( {
1355+ $ stateProvider. state ( {
13541356 name : "types" ,
13551357 url : "/types/{p1:string}/{p2:date}" ,
13561358 params : {
@@ -1359,7 +1361,7 @@ describe('state', function () {
13591361 nonurl : null
13601362 }
13611363 } ) ;
1362- stateProvider . state ( {
1364+ $ stateProvider. state ( {
13631365 name : "types.substate" ,
13641366 url : "/sub/{p3[]:int}/{p4:json}?{p5:bool}" ,
13651367 params : {
@@ -1627,33 +1629,33 @@ describe('state', function () {
16271629 describe ( 'provider decorators' , function ( ) {
16281630
16291631 it ( 'should return built-in decorators' , inject ( function ( $state ) {
1630- expect ( stateProvider . decorator ( 'parent' ) ( { parent : A } ) . self . name ) . toBe ( "A" ) ;
1632+ expect ( $ stateProvider. decorator ( 'parent' ) ( { parent : A } ) . self . name ) . toBe ( "A" ) ;
16311633 } ) ) ;
16321634
16331635 it ( 'should allow built-in decorators to be overridden' , inject ( function ( $state , $q ) {
1634- stateProvider . decorator ( 'data' , function ( state ) {
1636+ $ stateProvider. decorator ( 'data' , function ( state ) {
16351637 return angular . extend ( state . data || { } , { foo : "bar" } ) ;
16361638 } ) ;
1637- stateProvider . state ( 'AA' , { parent : A , data : { baz : "true" } } ) ;
1639+ $ stateProvider. state ( 'AA' , { parent : A , data : { baz : "true" } } ) ;
16381640
16391641 $state . transitionTo ( 'AA' ) ;
16401642 $q . flush ( ) ;
16411643 expect ( $state . current . data ) . toEqual ( { baz : 'true' , foo : 'bar' } ) ;
16421644 } ) ) ;
16431645
16441646 it ( 'should allow new decorators to be added' , inject ( function ( $state , $q ) {
1645- stateProvider . decorator ( 'custom' , function ( state ) {
1647+ $ stateProvider. decorator ( 'custom' , function ( state ) {
16461648 return function ( ) { return "Custom functionality for state '" + state + "'" } ;
16471649 } ) ;
1648- stateProvider . state ( 'decoratorTest' , { } ) ;
1650+ $ stateProvider. state ( 'decoratorTest' , { } ) ;
16491651
16501652 $state . transitionTo ( 'decoratorTest' ) ;
16511653 $q . flush ( ) ;
16521654 expect ( $state . $current . custom ( ) ) . toBe ( "Custom functionality for state 'decoratorTest'" ) ;
16531655 } ) ) ;
16541656
16551657 it ( 'should allow built-in decorators to be extended' , inject ( function ( $state , $q , $httpBackend ) {
1656- stateProvider . decorator ( 'views' , function ( state , parent ) {
1658+ $ stateProvider. decorator ( 'views' , function ( state , parent ) {
16571659 var result = { } ;
16581660
16591661 var views = parent ( state ) ;
@@ -1666,7 +1668,7 @@ describe('state', function () {
16661668 return result ;
16671669 } ) ;
16681670
1669- stateProvider . state ( 'viewTest' , {
1671+ $ stateProvider. state ( 'viewTest' , {
16701672 views : {
16711673 "viewA@" : { template : '<div/>' } ,
16721674 "viewB@" : { template : '<div/>' }
@@ -1685,10 +1687,10 @@ describe('state', function () {
16851687 function decorator1 ( state , parent ) { d . d1 = true ; return parent ( state ) ; }
16861688 function decorator2 ( state , parent ) { d . d2 = true ; return parent ( state ) ; }
16871689
1688- stateProvider . decorator ( 'parent' , decorator1 ) ;
1689- stateProvider . decorator ( 'parent' , decorator2 ) ;
1690+ $ stateProvider. decorator ( 'parent' , decorator1 ) ;
1691+ $ stateProvider. decorator ( 'parent' , decorator2 ) ;
16901692
1691- stateProvider . state ( { name : "test" , parent : A } ) ;
1693+ $ stateProvider. state ( { name : "test" , parent : A } ) ;
16921694 $state . go ( "test" ) ; $q . flush ( ) ;
16931695
16941696 expect ( $state . $current . name ) . toBe ( "test" ) ;
@@ -1702,10 +1704,10 @@ describe('state', function () {
17021704 function decorator1 ( state , parent ) { d . d1 = true ; return parent ( state ) ; }
17031705 function decorator2 ( state , parent ) { d . d2 = true ; return { } ; }
17041706
1705- stateProvider . decorator ( 'data' , decorator1 ) ;
1706- stateProvider . decorator ( 'data' , decorator2 ) ;
1707+ $ stateProvider. decorator ( 'data' , decorator1 ) ;
1708+ $ stateProvider. decorator ( 'data' , decorator2 ) ;
17071709
1708- stateProvider . state ( { name : "test" , data : { x : 1 } } ) ;
1710+ $ stateProvider. state ( { name : "test" , data : { x : 1 } } ) ;
17091711 $state . go ( "test" ) ; $q . flush ( ) ;
17101712
17111713 expect ( $state . $current . name ) . toBe ( "test" ) ;
@@ -1719,10 +1721,10 @@ describe('state', function () {
17191721 function decorator1 ( state , parent ) { d . d1 = true ; return angular . extend ( parent ( state ) , { y : 2 } ) ; }
17201722 function decorator2 ( state , parent ) { d . d2 = true ; return angular . extend ( parent ( state ) , { z : 3 } ) ; }
17211723
1722- stateProvider . decorator ( 'data' , decorator1 ) ;
1723- stateProvider . decorator ( 'data' , decorator2 ) ;
1724+ $ stateProvider. decorator ( 'data' , decorator1 ) ;
1725+ $ stateProvider. decorator ( 'data' , decorator2 ) ;
17241726
1725- stateProvider . state ( { name : "test" , data : { x : 1 } } ) ;
1727+ $ stateProvider. state ( { name : "test" , data : { x : 1 } } ) ;
17261728 $state . go ( "test" ) ; $q . flush ( ) ;
17271729
17281730 expect ( $state . $current . name ) . toBe ( "test" ) ;
0 commit comments