@@ -246,8 +246,10 @@ describe('tooltip', function() {
246
246
} ) ;
247
247
248
248
describe ( 'with specified popup delay' , function ( ) {
249
- beforeEach ( inject ( function ( $compile ) {
250
- scope . delay = '1000' ;
249
+ var $timeout ;
250
+ beforeEach ( inject ( function ( $compile , _$timeout_ ) {
251
+ $timeout = _$timeout_ ;
252
+ scope . delay = '1000' ;
251
253
elm = $compile ( angular . element (
252
254
'<span tooltip="tooltip text" tooltip-popup-delay="{{delay}}" ng-disabled="disabled">Selector Text</span>'
253
255
) ) ( scope ) ;
@@ -256,22 +258,22 @@ describe('tooltip', function() {
256
258
scope . $digest ( ) ;
257
259
} ) ) ;
258
260
259
- it ( 'should open after timeout' , inject ( function ( $timeout ) {
261
+ it ( 'should open after timeout' , function ( ) {
260
262
elm . trigger ( 'mouseenter' ) ;
261
263
expect ( tooltipScope . isOpen ) . toBe ( false ) ;
262
264
263
265
$timeout . flush ( ) ;
264
266
expect ( tooltipScope . isOpen ) . toBe ( true ) ;
265
- } ) ) ;
267
+ } ) ;
266
268
267
- it ( 'should not open if mouseleave before timeout' , inject ( function ( $timeout ) {
269
+ it ( 'should not open if mouseleave before timeout' , function ( ) {
268
270
elm . trigger ( 'mouseenter' ) ;
269
271
expect ( tooltipScope . isOpen ) . toBe ( false ) ;
270
272
271
273
elm . trigger ( 'mouseleave' ) ;
272
274
$timeout . flush ( ) ;
273
275
expect ( tooltipScope . isOpen ) . toBe ( false ) ;
274
- } ) ) ;
276
+ } ) ;
275
277
276
278
it ( 'should use default popup delay if specified delay is not a number' , function ( ) {
277
279
scope . delay = 'text1000' ;
@@ -280,7 +282,7 @@ describe('tooltip', function() {
280
282
expect ( tooltipScope . isOpen ) . toBe ( true ) ;
281
283
} ) ;
282
284
283
- it ( 'should not open if disabled is present' , inject ( function ( $timeout ) {
285
+ it ( 'should not open if disabled is present' , function ( ) {
284
286
elm . trigger ( 'mouseenter' ) ;
285
287
expect ( tooltipScope . isOpen ) . toBe ( false ) ;
286
288
@@ -291,10 +293,30 @@ describe('tooltip', function() {
291
293
292
294
$timeout . flush ( ) ;
293
295
expect ( tooltipScope . isOpen ) . toBe ( false ) ;
294
- } ) ) ;
296
+ } ) ;
297
+
298
+ it ( 'should open when not disabled after being disabled - issue #4204' , function ( ) {
299
+ elm . trigger ( 'mouseenter' ) ;
300
+ expect ( tooltipScope . isOpen ) . toBe ( false ) ;
301
+
302
+ $timeout . flush ( 500 ) ;
303
+ elmScope . disabled = true ;
304
+ elmScope . $digest ( ) ;
305
+
306
+ $timeout . flush ( 500 ) ;
307
+ expect ( tooltipScope . isOpen ) . toBe ( false ) ;
308
+
309
+ elmScope . disabled = false ;
310
+ elmScope . $digest ( ) ;
311
+
312
+ elm . trigger ( 'mouseenter' ) ;
313
+ $timeout . flush ( ) ;
314
+
315
+ expect ( tooltipScope . isOpen ) . toBe ( true ) ;
316
+ } ) ;
295
317
} ) ;
296
-
297
- describe ( 'with an is-open attribute' , function ( ) {
318
+
319
+ describe ( 'with an is-open attribute' , function ( ) {
298
320
beforeEach ( inject ( function ( $compile ) {
299
321
scope . isOpen = false ;
300
322
elm = $compile ( angular . element (
@@ -304,7 +326,7 @@ describe('tooltip', function() {
304
326
tooltipScope = elmScope . $$childTail ;
305
327
scope . $digest ( ) ;
306
328
} ) ) ;
307
-
329
+
308
330
it ( 'should show and hide with the controller value' , function ( ) {
309
331
expect ( tooltipScope . isOpen ) . toBe ( false ) ;
310
332
elmScope . isOpen = true ;
@@ -314,7 +336,7 @@ describe('tooltip', function() {
314
336
elmScope . $digest ( ) ;
315
337
expect ( tooltipScope . isOpen ) . toBe ( false ) ;
316
338
} ) ;
317
-
339
+
318
340
it ( 'should update the controller value' , function ( ) {
319
341
elm . trigger ( 'mouseenter' ) ;
320
342
expect ( elmScope . isOpen ) . toBe ( true ) ;
@@ -412,7 +434,7 @@ describe('tooltip', function() {
412
434
elm . trigger ( 'fakeTriggerAttr' ) ;
413
435
expect ( tooltipScope . isOpen ) . toBeFalsy ( ) ;
414
436
} ) ) ;
415
-
437
+
416
438
it ( 'should not show when trigger is set to "none"' , inject ( function ( $compile ) {
417
439
elmBody = angular . element (
418
440
'<div><input tooltip="Hello!" tooltip-trigger="none" /></div>'
0 commit comments