1
1
describe ( 'state' , function ( ) {
2
2
3
- var locationProvider ;
3
+ var locationProvider , templateParams ;
4
4
5
5
beforeEach ( module ( 'ui.router' , function ( $locationProvider ) {
6
6
locationProvider = $locationProvider ;
@@ -50,7 +50,14 @@ describe('state', function () {
50
50
. state ( 'about' , { url : "/about" } )
51
51
. state ( 'about.person' , { url : "/:person" } )
52
52
. 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
+ } ) ;
54
61
55
62
$provide . value ( 'AppInjectable' , AppInjectable ) ;
56
63
} ) ) ;
@@ -442,8 +449,7 @@ describe('state', function () {
442
449
443
450
describe ( 'default properties' , function ( ) {
444
451
it ( 'should always have a name' , inject ( function ( $state , $q ) {
445
- $state . transitionTo ( A ) ;
446
- $q . flush ( ) ;
452
+ $state . transitionTo ( A ) ; $q . flush ( ) ;
447
453
expect ( $state . $current . name ) . toBe ( 'A' ) ;
448
454
expect ( $state . $current . toString ( ) ) . toBe ( 'A' ) ;
449
455
} ) ) ;
@@ -453,9 +459,16 @@ describe('state', function () {
453
459
} ) ) ;
454
460
455
461
it ( 'should include itself and parent states' , inject ( function ( $state , $q ) {
456
- $state . transitionTo ( DD ) ;
457
- $q . flush ( ) ;
462
+ $state . transitionTo ( DD ) ; $q . flush ( ) ;
458
463
expect ( $state . $current . includes ) . toEqual ( { '' : true , D : true , DD : true } ) ;
459
464
} ) ) ;
460
465
} ) ;
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
+ } ) ;
461
474
} ) ;
0 commit comments