@@ -393,6 +393,13 @@ describe('state', function () {
393
393
it ( 'should return undefined when queried state does not exist' , inject ( function ( $state ) {
394
394
expect ( $state . is ( 'Z' ) ) . toBeUndefined ( ) ;
395
395
} ) ) ;
396
+
397
+ it ( 'should return true when the current state is passed with matching parameters' , inject ( function ( $state , $q ) {
398
+ $state . transitionTo ( D , { x : 'foo' , y : 'bar' } ) ; $q . flush ( ) ;
399
+ expect ( $state . is ( D , { x : 'foo' , y : 'bar' } ) ) . toBe ( true ) ;
400
+ expect ( $state . is ( 'D' , { x : 'foo' , y : 'bar' } ) ) . toBe ( true ) ;
401
+ expect ( $state . is ( D , { x : 'bar' , y : 'foo' } ) ) . toBe ( false ) ;
402
+ } ) ) ;
396
403
} ) ;
397
404
398
405
describe ( '.includes()' , function ( ) {
@@ -411,7 +418,21 @@ describe('state', function () {
411
418
} ) ) ;
412
419
413
420
it ( 'should return undefined when queried state does not exist' , inject ( function ( $state ) {
414
- expect ( $state . is ( 'Z' ) ) . toBeUndefined ( ) ;
421
+ expect ( $state . includes ( 'Z' ) ) . toBeUndefined ( ) ;
422
+ } ) ) ;
423
+
424
+ it ( 'should return true when the current state is passed with partial matching parameters' , inject ( function ( $state , $q ) {
425
+ $state . transitionTo ( D , { x : 'foo' , y : 'bar' } ) ; $q . flush ( ) ;
426
+ expect ( $state . includes ( D , { x : 'foo' } ) ) . toBe ( true ) ;
427
+ expect ( $state . includes ( D , { y : 'bar' } ) ) . toBe ( true ) ;
428
+ expect ( $state . includes ( 'D' , { x : 'foo' } ) ) . toBe ( true ) ;
429
+ expect ( $state . includes ( D , { y : 'foo' } ) ) . toBe ( false ) ;
430
+ } ) ) ;
431
+
432
+ it ( 'should return true when the current state is passed with partial matching parameters from state\'s parent' , inject ( function ( $state , $q ) {
433
+ $state . transitionTo ( 'about.person.item' , { person : 'bob' , id : 5 } ) ; $q . flush ( ) ;
434
+ expect ( $state . includes ( 'about.person' , { person : 'bob' } ) ) . toBe ( true ) ;
435
+ expect ( $state . includes ( 'about.person' , { person : 'steve' } ) ) . toBe ( false ) ;
415
436
} ) ) ;
416
437
} ) ;
417
438
0 commit comments