@@ -212,18 +212,42 @@ describe('state', function () {
212212
213213 describe ( '.go()' , function ( ) {
214214 it ( 'transitions to a relative state' , inject ( function ( $state , $q ) {
215- $state . transitionTo ( 'about.person.item' , { id : 5 } ) ;
216- $q . flush ( ) ;
217- $state . go ( '^.^.sidebar' ) ;
218- $q . flush ( ) ;
215+ $state . transitionTo ( 'about.person.item' , { id : 5 } ) ; $q . flush ( ) ;
216+ $state . go ( '^.^.sidebar' ) ; $q . flush ( ) ;
217+ expect ( $state . $current . name ) . toBe ( 'about.sidebar' ) ;
218+
219+ // Transitions to absolute state
220+ $state . go ( "home" ) ; $q . flush ( ) ;
221+ expect ( $state . $current . name ) . toBe ( 'home' ) ;
222+
223+
224+ // Transition to a child state
225+ $state . go ( ".item" , { id : 5 } ) ; $q . flush ( ) ;
226+ expect ( $state . $current . name ) . toBe ( 'home.item' ) ;
227+
228+ // Transition to grandparent's sibling through root
229+ // (Equivalent to absolute transition, assuming the root is known).
230+ $state . go ( "^.^.about" ) ; $q . flush ( ) ;
231+ expect ( $state . $current . name ) . toBe ( 'about' ) ;
232+
233+ // Transition to grandchild
234+ $state . go ( ".person.item" , { person : "bob" , id : 13 } ) ; $q . flush ( ) ;
235+ expect ( $state . $current . name ) . toBe ( 'about.person.item' ) ;
236+
237+ // Transition to immediate parent
238+ $state . go ( "^" ) ; $q . flush ( ) ;
239+ expect ( $state . $current . name ) . toBe ( 'about.person' ) ;
240+
241+ // Transition to parent's sibling
242+ $state . go ( "^.sidebar" ) ; $q . flush ( ) ;
219243 expect ( $state . $current . name ) . toBe ( 'about.sidebar' ) ;
220244 } ) ) ;
221245
222246 it ( 'keeps parameters from common ancestor states' , inject ( function ( $state , $stateParams , $q ) {
223247 $state . transitionTo ( 'about.person' , { person : 'bob' } ) ;
224248 $q . flush ( ) ;
225249
226- $state . go ( '^ item' , { id : 5 } ) ;
250+ $state . go ( '. item' , { id : 5 } ) ;
227251 $q . flush ( ) ;
228252
229253 expect ( $state . $current . name ) . toBe ( 'about.person.item' ) ;
0 commit comments