@@ -191,15 +191,12 @@ describe('tabs', function() {
191
191
} ) ;
192
192
193
193
describe ( 'ng-repeat' , function ( ) {
194
- beforeEach ( inject ( function ( $compile , $rootScope ) {
194
+ var $compile , $rootScope ;
195
+ beforeEach ( inject ( function ( _$compile_ , _$rootScope_ ) {
196
+ $compile = _$compile_ ;
197
+ $rootScope = _$rootScope_ ;
195
198
scope = $rootScope . $new ( ) ;
196
199
197
- function makeTab ( active ) {
198
- return {
199
- active : ! ! active ,
200
- select : jasmine . createSpy ( )
201
- } ;
202
- }
203
200
scope . tabs = [
204
201
makeTab ( ) , makeTab ( ) , makeTab ( true ) , makeTab ( )
205
202
] ;
@@ -214,6 +211,13 @@ describe('tabs', function() {
214
211
scope . $apply ( ) ;
215
212
} ) ) ;
216
213
214
+ function makeTab ( active ) {
215
+ return {
216
+ active : ! ! active ,
217
+ select : jasmine . createSpy ( )
218
+ } ;
219
+ }
220
+
217
221
function titles ( ) {
218
222
return elm . find ( 'ul.nav-tabs li' ) ;
219
223
}
@@ -263,6 +267,33 @@ describe('tabs', function() {
263
267
scope . $apply ( ) ;
264
268
expectTabActive ( scope . tabs [ 2 ] ) ;
265
269
} ) ;
270
+
271
+ it ( 'should not select twice' , function ( ) {
272
+ elm . remove ( ) ;
273
+ elm = null ;
274
+ scope = $rootScope . $new ( ) ;
275
+
276
+ scope . tabs = [
277
+ makeTab ( ) , makeTab ( ) , makeTab ( true ) , makeTab ( )
278
+ ] ;
279
+ scope . foo = { active : true } ;
280
+ scope . select = jasmine . createSpy ( ) ;
281
+ elm = $compile ( [
282
+ '<tabset>' ,
283
+ ' <tab ng-repeat="t in tabs" active="t.active" select="select()">' ,
284
+ ' <tab-heading><b>heading</b> {{index}}</tab-heading>' ,
285
+ ' content {{$index}}' ,
286
+ ' </tab>' ,
287
+ ' <tab active="foo.active" select="select()">' ,
288
+ ' <tab-heading><b>heading</b> foo</tab-heading>' ,
289
+ ' content foo' ,
290
+ ' </tab>' ,
291
+ '</tabset>'
292
+ ] . join ( '\n' ) ) ( scope ) ;
293
+ scope . $apply ( ) ;
294
+
295
+ expect ( scope . select . calls . count ( ) ) . toBe ( 1 ) ;
296
+ } ) ;
266
297
} ) ;
267
298
268
299
describe ( 'advanced tab-heading element' , function ( ) {
0 commit comments