@@ -212,18 +212,42 @@ describe('state', function () {
212
212
213
213
describe ( '.go()' , function ( ) {
214
214
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 ( ) ;
219
243
expect ( $state . $current . name ) . toBe ( 'about.sidebar' ) ;
220
244
} ) ) ;
221
245
222
246
it ( 'keeps parameters from common ancestor states' , inject ( function ( $state , $stateParams , $q ) {
223
247
$state . transitionTo ( 'about.person' , { person : 'bob' } ) ;
224
248
$q . flush ( ) ;
225
249
226
- $state . go ( '^ item' , { id : 5 } ) ;
250
+ $state . go ( '. item' , { id : 5 } ) ;
227
251
$q . flush ( ) ;
228
252
229
253
expect ( $state . $current . name ) . toBe ( 'about.person.item' ) ;
0 commit comments