1
1
describe ( 'dropdownToggle' , function ( ) {
2
- var $compile , $rootScope , $document , $templateCache , dropdownConfig , element ;
2
+ var $compile , $rootScope , $document , $templateCache , dropdownConfig , element , $browser ;
3
3
4
4
beforeEach ( module ( 'ui.bootstrap.dropdown' ) ) ;
5
5
6
- beforeEach ( inject ( function ( _$compile_ , _$rootScope_ , _$document_ , _$templateCache_ , _dropdownConfig_ ) {
6
+ beforeEach ( inject ( function ( _$compile_ , _$rootScope_ , _$document_ , _$templateCache_ , _dropdownConfig_ , _$browser_ ) {
7
7
$compile = _$compile_ ;
8
8
$rootScope = _$rootScope_ ;
9
9
$document = _$document_ ;
10
10
$templateCache = _$templateCache_ ;
11
11
dropdownConfig = _dropdownConfig_ ;
12
+ $browser = _$browser_ ;
12
13
} ) ) ;
13
14
14
15
afterEach ( function ( ) {
@@ -322,9 +323,11 @@ describe('dropdownToggle', function() {
322
323
it ( 'should call it correctly when toggles' , function ( ) {
323
324
$rootScope . isopen = true ;
324
325
$rootScope . $digest ( ) ;
326
+ $browser . defer . flush ( ) ;
325
327
expect ( $rootScope . toggleHandler ) . toHaveBeenCalledWith ( true ) ;
326
328
327
329
clickDropdownToggle ( ) ;
330
+ $browser . defer . flush ( ) ;
328
331
expect ( $rootScope . toggleHandler ) . toHaveBeenCalledWith ( false ) ;
329
332
} ) ;
330
333
} ) ;
@@ -338,16 +341,19 @@ describe('dropdownToggle', function() {
338
341
} ) ;
339
342
340
343
it ( 'should not have been called initially' , function ( ) {
344
+ $browser . defer . flush ( ) ;
341
345
expect ( $rootScope . toggleHandler ) . not . toHaveBeenCalled ( ) ;
342
346
} ) ;
343
347
344
348
it ( 'should call it correctly when toggles' , function ( ) {
345
349
$rootScope . isopen = false ;
346
350
$rootScope . $digest ( ) ;
351
+ $browser . defer . flush ( ) ;
347
352
expect ( $rootScope . toggleHandler ) . toHaveBeenCalledWith ( false ) ;
348
353
349
354
$rootScope . isopen = true ;
350
355
$rootScope . $digest ( ) ;
356
+ $browser . defer . flush ( ) ;
351
357
expect ( $rootScope . toggleHandler ) . toHaveBeenCalledWith ( true ) ;
352
358
} ) ;
353
359
} ) ;
@@ -360,14 +366,17 @@ describe('dropdownToggle', function() {
360
366
} ) ;
361
367
362
368
it ( 'should not have been called initially' , function ( ) {
369
+ $browser . defer . flush ( ) ;
363
370
expect ( $rootScope . toggleHandler ) . not . toHaveBeenCalled ( ) ;
364
371
} ) ;
365
372
366
373
it ( 'should call it when clicked' , function ( ) {
367
374
clickDropdownToggle ( ) ;
375
+ $browser . defer . flush ( ) ;
368
376
expect ( $rootScope . toggleHandler ) . toHaveBeenCalledWith ( true ) ;
369
377
370
378
clickDropdownToggle ( ) ;
379
+ $browser . defer . flush ( ) ;
371
380
expect ( $rootScope . toggleHandler ) . toHaveBeenCalledWith ( false ) ;
372
381
} ) ;
373
382
} ) ;
0 commit comments