@@ -36,7 +36,7 @@ describe('ngSwitch', function() {
36
36
} ) ) ;
37
37
38
38
39
- it ( 'should show all switch-whens that match the current value' , inject ( function ( $rootScope , $compile , $$rAF ) {
39
+ it ( 'should show all switch-whens that match the current value' , inject ( function ( $rootScope , $compile ) {
40
40
element = $compile (
41
41
'<ul ng-switch="select">' +
42
42
'<li ng-switch-when="1">first:{{name}}</li>' +
@@ -57,15 +57,13 @@ describe('ngSwitch', function() {
57
57
58
58
$rootScope . select = 2 ;
59
59
$rootScope . $apply ( ) ;
60
- $$rAF . flush ( ) ;
61
60
expect ( element . text ( ) ) . toEqual ( 'second:shyam' ) ;
62
61
$rootScope . name = 'misko' ;
63
62
$rootScope . $apply ( ) ;
64
63
expect ( element . text ( ) ) . toEqual ( 'second:misko' ) ;
65
64
66
65
$rootScope . select = true ;
67
66
$rootScope . $apply ( ) ;
68
- $$rAF . flush ( ) ;
69
67
expect ( element . text ( ) ) . toEqual ( 'true:misko' ) ;
70
68
} ) ) ;
71
69
@@ -282,7 +280,7 @@ describe('ngSwitch', function() {
282
280
} ) ) ;
283
281
284
282
285
- it ( 'should properly support case labels with different numbers of transclude fns' , inject ( function ( $rootScope , $compile , $$rAF ) {
283
+ it ( 'should properly support case labels with different numbers of transclude fns' , inject ( function ( $rootScope , $compile ) {
286
284
element = $compile (
287
285
'<div ng-switch="mode">' +
288
286
'<p ng-switch-when="a">Block1</p>' +
@@ -296,11 +294,9 @@ describe('ngSwitch', function() {
296
294
297
295
$rootScope . $apply ( 'mode = "b"' ) ;
298
296
expect ( element . children ( ) . length ) . toBe ( 1 ) ;
299
- $$rAF . flush ( ) ;
300
297
301
298
$rootScope . $apply ( 'mode = "a"' ) ;
302
299
expect ( element . children ( ) . length ) . toBe ( 2 ) ;
303
- $$rAF . flush ( ) ;
304
300
305
301
$rootScope . $apply ( 'mode = "b"' ) ;
306
302
expect ( element . children ( ) . length ) . toBe ( 1 ) ;
@@ -324,7 +320,9 @@ describe('ngSwitch', function() {
324
320
$rootScope . $apply ( ) ;
325
321
spy . calls . reset ( ) ;
326
322
expect ( element . text ( ) ) . toEqual ( 'second' ) ;
327
- // The animation completion is async even without actual animations
323
+ // If ngSwitch re-introduces code that triggers a digest after an element is removed (in an
324
+ // animation .then callback), flushing the queue ensures the callback will be called, and the test
325
+ // fails
328
326
$$rAF . flush ( ) ;
329
327
330
328
expect ( spy ) . not . toHaveBeenCalled ( ) ;
@@ -334,7 +332,7 @@ describe('ngSwitch', function() {
334
332
335
333
336
334
it ( 'should handle changes to the switch value in a digest loop with multiple value matches' ,
337
- inject ( function ( $$rAF , $ compile, $rootScope , $timeout ) {
335
+ inject ( function ( $compile , $rootScope ) {
338
336
var scope = $rootScope . $new ( ) ;
339
337
scope . value = 'foo' ;
340
338
@@ -364,11 +362,6 @@ describe('ngSwitch', function() {
364
362
365
363
366
364
describe ( 'ngSwitchWhen separator' , function ( ) {
367
- var $$rAF ;
368
-
369
- beforeEach ( inject ( function ( _$$rAF_ ) {
370
- $$rAF = _$$rAF_ ;
371
- } ) ) ;
372
365
373
366
it ( 'should be possible to define a separator' , inject ( function ( $rootScope , $compile ) {
374
367
element = $compile (
@@ -383,12 +376,10 @@ describe('ngSwitch', function() {
383
376
expect ( element . children ( ) . length ) . toBe ( 2 ) ;
384
377
expect ( element . text ( ) ) . toBe ( 'Block1|Block2|' ) ;
385
378
$rootScope . $apply ( 'mode = "b"' ) ;
386
- $$rAF . flush ( ) ;
387
379
388
380
expect ( element . children ( ) . length ) . toBe ( 1 ) ;
389
381
expect ( element . text ( ) ) . toBe ( 'Block1|' ) ;
390
382
$rootScope . $apply ( 'mode = "c"' ) ;
391
- $$rAF . flush ( ) ;
392
383
393
384
expect ( element . children ( ) . length ) . toBe ( 1 ) ;
394
385
expect ( element . text ( ) ) . toBe ( 'Block3|' ) ;
@@ -408,12 +399,10 @@ describe('ngSwitch', function() {
408
399
expect ( element . children ( ) . length ) . toBe ( 2 ) ;
409
400
expect ( element . text ( ) ) . toBe ( 'Block1|Block2|' ) ;
410
401
$rootScope . $apply ( 'mode = ""' ) ;
411
- $$rAF . flush ( ) ;
412
402
413
403
expect ( element . children ( ) . length ) . toBe ( 1 ) ;
414
404
expect ( element . text ( ) ) . toBe ( 'Block1|' ) ;
415
405
$rootScope . $apply ( 'mode = "c"' ) ;
416
- $$rAF . flush ( ) ;
417
406
418
407
expect ( element . children ( ) . length ) . toBe ( 1 ) ;
419
408
expect ( element . text ( ) ) . toBe ( 'Block3|' ) ;
@@ -433,12 +422,10 @@ describe('ngSwitch', function() {
433
422
expect ( element . children ( ) . length ) . toBe ( 2 ) ;
434
423
expect ( element . text ( ) ) . toBe ( 'Block1|Block2|' ) ;
435
424
$rootScope . $apply ( 'mode = "b"' ) ;
436
- $$rAF . flush ( ) ;
437
425
438
426
expect ( element . children ( ) . length ) . toBe ( 1 ) ;
439
427
expect ( element . text ( ) ) . toBe ( 'Block1|' ) ;
440
428
$rootScope . $apply ( 'mode = "c"' ) ;
441
- $$rAF . flush ( ) ;
442
429
443
430
expect ( element . children ( ) . length ) . toBe ( 1 ) ;
444
431
expect ( element . text ( ) ) . toBe ( 'Block3|' ) ;
@@ -458,12 +445,10 @@ describe('ngSwitch', function() {
458
445
expect ( element . children ( ) . length ) . toBe ( 2 ) ;
459
446
expect ( element . text ( ) ) . toBe ( 'Block1|Block2|' ) ;
460
447
$rootScope . $apply ( 'mode = "b|a"' ) ;
461
- $$rAF . flush ( ) ;
462
448
463
449
expect ( element . children ( ) . length ) . toBe ( 1 ) ;
464
450
expect ( element . text ( ) ) . toBe ( 'Block1|' ) ;
465
451
$rootScope . $apply ( 'mode = "c"' ) ;
466
- $$rAF . flush ( ) ;
467
452
468
453
expect ( element . children ( ) . length ) . toBe ( 1 ) ;
469
454
expect ( element . text ( ) ) . toBe ( 'Block3|' ) ;
@@ -483,12 +468,10 @@ describe('ngSwitch', function() {
483
468
expect ( element . children ( ) . length ) . toBe ( 2 ) ;
484
469
expect ( element . text ( ) ) . toBe ( 'Block1|Block2|' ) ;
485
470
$rootScope . $apply ( 'mode = "b"' ) ;
486
- $$rAF . flush ( ) ;
487
471
488
472
expect ( element . children ( ) . length ) . toBe ( 1 ) ;
489
473
expect ( element . text ( ) ) . toBe ( 'Block1|' ) ;
490
474
$rootScope . $apply ( 'mode = "c"' ) ;
491
- $$rAF . flush ( ) ;
492
475
493
476
expect ( element . children ( ) . length ) . toBe ( 1 ) ;
494
477
expect ( element . text ( ) ) . toBe ( 'Block3|' ) ;
0 commit comments