@@ -1112,4 +1112,49 @@ describe('uiSrefActive', function() {
1112
1112
expect ( el . hasClass ( 'active' ) ) . toBeTruthy ( ) ;
1113
1113
} ) ) ;
1114
1114
} ) ;
1115
+
1116
+ describe ( 'ng-{class,style} interface, and handle values as arrays' , function ( ) {
1117
+ it ( 'should match on abstract states that are included by the current state' , inject ( function ( $rootScope , $compile , $state , $q ) {
1118
+ el = $compile ( '<div ui-sref-active="{active: [\'randomState.**\', \'admin.roles\']}"><a ui-sref-active="active" ui-sref="admin.roles">Roles</a></div>' ) ( $rootScope ) ;
1119
+ $state . transitionTo ( 'admin.roles' ) ;
1120
+ $q . flush ( ) ;
1121
+ timeoutFlush ( ) ;
1122
+ var abstractParent = el [ 0 ] ;
1123
+ expect ( abstractParent . className ) . toMatch ( / a c t i v e / ) ;
1124
+ var child = el [ 0 ] . querySelector ( 'a' ) ;
1125
+ expect ( child . className ) . toMatch ( / a c t i v e / ) ;
1126
+ } ) ) ;
1127
+
1128
+ it ( 'should match on state parameters' , inject ( function ( $compile , $rootScope , $state , $q ) {
1129
+ el = $compile ( '<div ui-sref-active="{active: [\'admin.roles({page: 1})\']}"></div>' ) ( $rootScope ) ;
1130
+ $state . transitionTo ( 'admin.roles' , { page : 1 } ) ;
1131
+ $q . flush ( ) ;
1132
+ timeoutFlush ( ) ;
1133
+ expect ( el [ 0 ] . className ) . toMatch ( / a c t i v e / ) ;
1134
+ } ) ) ;
1135
+
1136
+ it ( 'should support multiple <className, stateOrName> pairs' , inject ( function ( $compile , $rootScope , $state , $q ) {
1137
+ el = $compile ( '<div ui-sref-active="{contacts: [\'contacts.item\', \'contacts.item.detail\'], admin: \'admin.roles({page: 1})\'}"></div>' ) ( $rootScope ) ;
1138
+ $state . transitionTo ( 'contacts.item.detail' , { id : 1 , foo : 'bar' } ) ;
1139
+ $q . flush ( ) ;
1140
+ timeoutFlush ( ) ;
1141
+ expect ( el [ 0 ] . className ) . toMatch ( / c o n t a c t s / ) ;
1142
+ expect ( el [ 0 ] . className ) . not . toMatch ( / a d m i n / ) ;
1143
+ $state . transitionTo ( 'admin.roles' , { page : 1 } ) ;
1144
+ $q . flush ( ) ;
1145
+ timeoutFlush ( ) ;
1146
+ expect ( el [ 0 ] . className ) . toMatch ( / a d m i n / ) ;
1147
+ expect ( el [ 0 ] . className ) . not . toMatch ( / c o n t a c t s / ) ;
1148
+ } ) ) ;
1149
+
1150
+ it ( 'should update the active classes when compiled' , inject ( function ( $compile , $rootScope , $document , $state , $q ) {
1151
+ $state . transitionTo ( 'admin.roles' ) ;
1152
+ $q . flush ( ) ;
1153
+ timeoutFlush ( ) ;
1154
+ el = $compile ( '<div ui-sref-active="{active: [\'admin.roles\', \'admin.someOtherState\']}"/>' ) ( $rootScope ) ;
1155
+ $rootScope . $digest ( ) ;
1156
+ timeoutFlush ( ) ;
1157
+ expect ( el . hasClass ( 'active' ) ) . toBeTruthy ( ) ;
1158
+ } ) ) ;
1159
+ } ) ;
1115
1160
} ) ;
0 commit comments