@@ -392,11 +392,12 @@ describe('uiStateRef', function() {
392
392
} ) ;
393
393
394
394
describe ( 'uiSrefActive' , function ( ) {
395
- var el , template , scope , document ;
395
+ var el , template , scope , document , _stateProvider ;
396
396
397
397
beforeEach ( module ( 'ui.router' ) ) ;
398
398
399
399
beforeEach ( module ( function ( $stateProvider ) {
400
+ _stateProvider = $stateProvider ;
400
401
$stateProvider . state ( 'top' , {
401
402
url : ''
402
403
} ) . state ( 'contacts' , {
@@ -511,6 +512,42 @@ describe('uiSrefActive', function() {
511
512
$q . flush ( ) ;
512
513
expect ( angular . element ( template [ 0 ] ) . attr ( 'class' ) ) . toBe ( 'ng-scope active' ) ;
513
514
} ) ) ;
515
+
516
+ it ( 'should match fuzzy on lazy loaded states' , inject ( function ( $rootScope , $q , $compile , $state ) {
517
+ el = angular . element ( '<div><a ui-sref="contacts.lazy" ui-sref-active="active">Lazy Contact</a></div>' ) ;
518
+ template = $compile ( el ) ( $rootScope ) ;
519
+ $rootScope . $digest ( ) ;
520
+
521
+ $rootScope . $on ( '$stateNotFound' , function ( ) {
522
+ _stateProvider . state ( 'contacts.lazy' , { } ) ;
523
+ } ) ;
524
+
525
+ $state . transitionTo ( 'contacts.item' , { id : 1 } ) ;
526
+ $q . flush ( ) ;
527
+ expect ( angular . element ( template [ 0 ] . querySelector ( 'a' ) ) . attr ( 'class' ) ) . toBe ( '' ) ;
528
+
529
+ $state . transitionTo ( 'contacts.lazy' ) ;
530
+ $q . flush ( ) ;
531
+ expect ( angular . element ( template [ 0 ] . querySelector ( 'a' ) ) . attr ( 'class' ) ) . toBe ( 'active' ) ;
532
+ } ) ) ;
533
+
534
+ it ( 'should match exactly on lazy loaded states' , inject ( function ( $rootScope , $q , $compile , $state ) {
535
+ el = angular . element ( '<div><a ui-sref="contacts.lazy" ui-sref-active-eq="active">Lazy Contact</a></div>' ) ;
536
+ template = $compile ( el ) ( $rootScope ) ;
537
+ $rootScope . $digest ( ) ;
538
+
539
+ $rootScope . $on ( '$stateNotFound' , function ( ) {
540
+ _stateProvider . state ( 'contacts.lazy' , { } ) ;
541
+ } ) ;
542
+
543
+ $state . transitionTo ( 'contacts.item' , { id : 1 } ) ;
544
+ $q . flush ( ) ;
545
+ expect ( angular . element ( template [ 0 ] . querySelector ( 'a' ) ) . attr ( 'class' ) ) . toBe ( '' ) ;
546
+
547
+ $state . transitionTo ( 'contacts.lazy' ) ;
548
+ $q . flush ( ) ;
549
+ expect ( angular . element ( template [ 0 ] . querySelector ( 'a' ) ) . attr ( 'class' ) ) . toBe ( 'active' ) ;
550
+ } ) ) ;
514
551
} ) ;
515
552
516
553
describe ( 'uiView controllers or onEnter handlers' , function ( ) {
0 commit comments