11describe ( 'dropdownToggle' , function ( ) {
2- var $compile , $rootScope , $document , $templateCache , dropdownConfig , element ;
2+ var $compile , $rootScope , $document , $templateCache , dropdownConfig , element , $browser ;
33
44 beforeEach ( module ( 'ui.bootstrap.dropdown' ) ) ;
55
6- beforeEach ( inject ( function ( _$compile_ , _$rootScope_ , _$document_ , _$templateCache_ , _dropdownConfig_ ) {
6+ beforeEach ( inject ( function ( _$compile_ , _$rootScope_ , _$document_ , _$templateCache_ , _dropdownConfig_ , _$browser_ ) {
77 $compile = _$compile_ ;
88 $rootScope = _$rootScope_ ;
99 $document = _$document_ ;
1010 $templateCache = _$templateCache_ ;
1111 dropdownConfig = _dropdownConfig_ ;
12+ $browser = _$browser_ ;
1213 } ) ) ;
1314
1415 afterEach ( function ( ) {
@@ -322,9 +323,11 @@ describe('dropdownToggle', function() {
322323 it ( 'should call it correctly when toggles' , function ( ) {
323324 $rootScope . isopen = true ;
324325 $rootScope . $digest ( ) ;
326+ $browser . defer . flush ( ) ;
325327 expect ( $rootScope . toggleHandler ) . toHaveBeenCalledWith ( true ) ;
326328
327329 clickDropdownToggle ( ) ;
330+ $browser . defer . flush ( ) ;
328331 expect ( $rootScope . toggleHandler ) . toHaveBeenCalledWith ( false ) ;
329332 } ) ;
330333 } ) ;
@@ -338,16 +341,19 @@ describe('dropdownToggle', function() {
338341 } ) ;
339342
340343 it ( 'should not have been called initially' , function ( ) {
344+ $browser . defer . flush ( ) ;
341345 expect ( $rootScope . toggleHandler ) . not . toHaveBeenCalled ( ) ;
342346 } ) ;
343347
344348 it ( 'should call it correctly when toggles' , function ( ) {
345349 $rootScope . isopen = false ;
346350 $rootScope . $digest ( ) ;
351+ $browser . defer . flush ( ) ;
347352 expect ( $rootScope . toggleHandler ) . toHaveBeenCalledWith ( false ) ;
348353
349354 $rootScope . isopen = true ;
350355 $rootScope . $digest ( ) ;
356+ $browser . defer . flush ( ) ;
351357 expect ( $rootScope . toggleHandler ) . toHaveBeenCalledWith ( true ) ;
352358 } ) ;
353359 } ) ;
@@ -360,14 +366,17 @@ describe('dropdownToggle', function() {
360366 } ) ;
361367
362368 it ( 'should not have been called initially' , function ( ) {
369+ $browser . defer . flush ( ) ;
363370 expect ( $rootScope . toggleHandler ) . not . toHaveBeenCalled ( ) ;
364371 } ) ;
365372
366373 it ( 'should call it when clicked' , function ( ) {
367374 clickDropdownToggle ( ) ;
375+ $browser . defer . flush ( ) ;
368376 expect ( $rootScope . toggleHandler ) . toHaveBeenCalledWith ( true ) ;
369377
370378 clickDropdownToggle ( ) ;
379+ $browser . defer . flush ( ) ;
371380 expect ( $rootScope . toggleHandler ) . toHaveBeenCalledWith ( false ) ;
372381 } ) ;
373382 } ) ;
0 commit comments