11describe ( 'state' , function ( ) {
22
3- var locationProvider ;
3+ var locationProvider , templateParams ;
44
55 beforeEach ( module ( 'ui.router' , function ( $locationProvider ) {
66 locationProvider = $locationProvider ;
@@ -50,7 +50,14 @@ describe('state', function () {
5050 . state ( 'about' , { url : "/about" } )
5151 . state ( 'about.person' , { url : "/:person" } )
5252 . state ( 'about.person.item' , { url : "/:id" } )
53- . state ( 'about.sidebar' , { } ) ;
53+ . state ( 'about.sidebar' , { } )
54+ . state ( 'about.sidebar.item' , {
55+ url : "/:item" ,
56+ templateUrl : function ( params ) {
57+ templateParams = params ;
58+ return "/templates/" + params . item + ".html" ;
59+ }
60+ } ) ;
5461
5562 $provide . value ( 'AppInjectable' , AppInjectable ) ;
5663 } ) ) ;
@@ -442,8 +449,7 @@ describe('state', function () {
442449
443450 describe ( 'default properties' , function ( ) {
444451 it ( 'should always have a name' , inject ( function ( $state , $q ) {
445- $state . transitionTo ( A ) ;
446- $q . flush ( ) ;
452+ $state . transitionTo ( A ) ; $q . flush ( ) ;
447453 expect ( $state . $current . name ) . toBe ( 'A' ) ;
448454 expect ( $state . $current . toString ( ) ) . toBe ( 'A' ) ;
449455 } ) ) ;
@@ -453,9 +459,16 @@ describe('state', function () {
453459 } ) ) ;
454460
455461 it ( 'should include itself and parent states' , inject ( function ( $state , $q ) {
456- $state . transitionTo ( DD ) ;
457- $q . flush ( ) ;
462+ $state . transitionTo ( DD ) ; $q . flush ( ) ;
458463 expect ( $state . $current . includes ) . toEqual ( { '' : true , D : true , DD : true } ) ;
459464 } ) ) ;
460465 } ) ;
466+
467+ describe ( 'template handling' , function ( ) {
468+ it ( 'should inject $stateParams into templateUrl function' , inject ( function ( $state , $q , $httpBackend ) {
469+ $httpBackend . expectGET ( "/templates/foo.html" ) . respond ( "200" ) ;
470+ $state . transitionTo ( 'about.sidebar.item' , { item : "foo" } ) ; $q . flush ( ) ;
471+ expect ( templateParams ) . toEqual ( { item : "foo" } ) ;
472+ } ) ) ;
473+ } ) ;
461474} ) ;
0 commit comments