@@ -392,11 +392,12 @@ describe('uiStateRef', function() {
392392} ) ;
393393
394394describe ( 'uiSrefActive' , function ( ) {
395- var el , template , scope , document ;
395+ var el , template , scope , document , _stateProvider ;
396396
397397 beforeEach ( module ( 'ui.router' ) ) ;
398398
399399 beforeEach ( module ( function ( $stateProvider ) {
400+ _stateProvider = $stateProvider ;
400401 $stateProvider . state ( 'top' , {
401402 url : ''
402403 } ) . state ( 'contacts' , {
@@ -511,6 +512,42 @@ describe('uiSrefActive', function() {
511512 $q . flush ( ) ;
512513 expect ( angular . element ( template [ 0 ] ) . attr ( 'class' ) ) . toBe ( 'ng-scope active' ) ;
513514 } ) ) ;
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+ } ) ) ;
514551} ) ;
515552
516553describe ( 'uiView controllers or onEnter handlers' , function ( ) {
0 commit comments