@@ -210,6 +210,30 @@ describe('state', function () {
210210 } ) ) ;
211211 } ) ;
212212
213+ describe ( '.go()' , function ( ) {
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 ( ) ;
219+ expect ( $state . $current . name ) . toBe ( 'about.sidebar' ) ;
220+ } ) ) ;
221+
222+ it ( 'keeps parameters from common ancestor states' , inject ( function ( $state , $stateParams , $q ) {
223+ $state . transitionTo ( 'about.person' , { person : 'bob' } ) ;
224+ $q . flush ( ) ;
225+
226+ $state . go ( '^item' , { id : 5 } ) ;
227+ $q . flush ( ) ;
228+
229+ expect ( $state . $current . name ) . toBe ( 'about.person.item' ) ;
230+ expect ( $stateParams ) . toEqual ( { person : 'bob' , id : '5' } ) ;
231+
232+ $state . go ( '^.^.sidebar' ) ;
233+ $q . flush ( ) ;
234+ expect ( $state . $current . name ) . toBe ( 'about.sidebar' ) ;
235+ } ) ) ;
236+ } ) ;
213237
214238 describe ( '.current' , function ( ) {
215239 it ( 'is always defined' , inject ( function ( $state ) {
@@ -345,7 +369,7 @@ describe('state', function () {
345369 } ) ) ;
346370 } ) ;
347371
348- describe ( 'default properties' , function ( ) {
372+ describe ( 'default properties' , function ( ) {
349373 it ( 'should always have a name' , inject ( function ( $state , $q ) {
350374 $state . transitionTo ( A ) ;
351375 $q . flush ( ) ;
@@ -403,5 +427,11 @@ describe('state', function () {
403427 it ( 'should always have a resolve object' , inject ( function ( $state ) {
404428 expect ( $state . $current . resolve ) . toEqual ( { } ) ;
405429 } ) ) ;
430+
431+ it ( 'should include itself and parent states' , inject ( function ( $state , $q ) {
432+ $state . transitionTo ( DD ) ;
433+ $q . flush ( ) ;
434+ expect ( $state . $current . includes ) . toEqual ( { '' : true , D : true , DD : true } ) ;
435+ } ) ) ;
406436 } ) ;
407437} ) ;
0 commit comments