@@ -8,7 +8,7 @@ function getPreviousMockStates() {
88 states . push ( { name : 'aside2' , url : '/aside2' } ) ;
99
1010 // Root of main app states
11- states . push ( { name : 'top' , url : '/' } ) ;
11+ states . push ( { name : 'top' } ) ;
1212
1313 // Personnel tab
1414 states . push ( { name : 'top.people' , url : 'people' } ) ;
@@ -59,6 +59,15 @@ describe("$previousState", function () {
5959 expect ( $previousState . get ( ) ) . toBeNull ( ) ;
6060 } ) ) ;
6161
62+ // Test for #175
63+ it ( "should not capture root state (or non-navigable states)" , inject ( function ( $rootScope ) {
64+ testGo ( "top" , { entered : 'top' } ) ;
65+ testGo ( "top.cust" , { entered : 'top.cust' } ) ;
66+ var prev = $previousState . get ( ) ;
67+ expect ( prev ) . toBeDefined ( ) ;
68+ expect ( prev . state . name ) . toBe ( "top" ) ;
69+ } ) ) ;
70+
6271
6372 describe ( '.go()' , function ( ) {
6473 it ( "should transition back to the previous state" , function ( ) {
@@ -73,15 +82,15 @@ describe("$previousState", function () {
7382 describe ( '.get()' , function ( ) {
7483 // Test for #120
7584 it ( "should not return current state, after a transition is cancelled" , inject ( function ( $rootScope ) {
76- testGo ( "top" , { entered : 'top' } ) ;
77- testGo ( "top.people.managerlist" , { entered : [ 'top.people' , 'top.people .managerlist'] } ) ;
85+ testGo ( "top.people " , { entered : [ 'top' , 'top.people' ] } ) ;
86+ testGo ( "top.people.managerlist" , { entered : [ 'top.people.managerlist' ] } ) ;
7887
7988 var transitionNum = 0 ;
8089 $rootScope . $on ( "$stateChangeStart" , function ( evt ) { if ( transitionNum ++ === 0 ) { evt . preventDefault ( ) ; } } ) ;
8190
8291 testGo ( "top.inv.storelist" , undefined , { redirect : 'top.people.managerlist' } ) ; // Cancelled, so we're still at original state
8392
84- expect ( $previousState . get ( ) . state . name ) . toBe ( "top" ) ;
93+ expect ( $previousState . get ( ) . state . name ) . toBe ( "top.people " ) ;
8594 } ) )
8695 } ) ;
8796
0 commit comments