@@ -403,14 +403,26 @@ describe('dropdownToggle', function() {
403
403
expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( true ) ;
404
404
} ) ;
405
405
406
- it ( 'auto-close="outsideClick"' , function ( ) {
407
- element = dropdown ( 'outsideClick' ) ;
408
- clickDropdownToggle ( ) ;
409
- expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( true ) ;
410
- element . find ( 'ul li a' ) . click ( ) ;
411
- expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( true ) ;
412
- $document . click ( ) ;
413
- expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( false ) ;
406
+ describe ( 'outsideClick' , function ( ) {
407
+ it ( 'should close only on a click outside of the dropdown menu' , function ( ) {
408
+ element = dropdown ( 'outsideClick' ) ;
409
+ clickDropdownToggle ( ) ;
410
+ expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( true ) ;
411
+ element . find ( 'ul li a' ) . click ( ) ;
412
+ expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( true ) ;
413
+ $document . click ( ) ;
414
+ expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( false ) ;
415
+ } ) ;
416
+
417
+ it ( 'should work with dropdown-append-to-body' , function ( ) {
418
+ element = $compile ( '<li dropdown dropdown-append-to-body auto-close="outsideClick"><a href dropdown-toggle></a><ul class="dropdown-menu" id="dropdown-menu"><li><a href>Hello On Body</a></li></ul></li>' ) ( $rootScope ) ;
419
+ clickDropdownToggle ( ) ;
420
+ expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( true ) ;
421
+ $document . find ( '#dropdown-menu' ) . find ( 'li' ) . eq ( 0 ) . trigger ( 'click' ) ;
422
+ expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( true ) ;
423
+ $document . click ( ) ;
424
+ expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( false ) ;
425
+ } ) ;
414
426
} ) ;
415
427
416
428
it ( 'control with is-open' , function ( ) {
0 commit comments