@@ -412,14 +412,26 @@ describe('dropdownToggle', function() {
412
412
expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( true ) ;
413
413
} ) ;
414
414
415
- it ( 'auto-close="outsideClick"' , function ( ) {
416
- element = dropdown ( 'outsideClick' ) ;
417
- clickDropdownToggle ( ) ;
418
- expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( true ) ;
419
- element . find ( 'ul li a' ) . click ( ) ;
420
- expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( true ) ;
421
- $document . click ( ) ;
422
- expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( false ) ;
415
+ describe ( 'outsideClick' , function ( ) {
416
+ it ( 'should close only on a click outside of the dropdown menu' , function ( ) {
417
+ element = dropdown ( 'outsideClick' ) ;
418
+ clickDropdownToggle ( ) ;
419
+ expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( true ) ;
420
+ element . find ( 'ul li a' ) . click ( ) ;
421
+ expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( true ) ;
422
+ $document . click ( ) ;
423
+ expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( false ) ;
424
+ } ) ;
425
+
426
+ it ( 'should work with dropdown-append-to-body' , function ( ) {
427
+ 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 ) ;
428
+ clickDropdownToggle ( ) ;
429
+ expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( true ) ;
430
+ $document . find ( '#dropdown-menu' ) . find ( 'li' ) . eq ( 0 ) . trigger ( 'click' ) ;
431
+ expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( true ) ;
432
+ $document . click ( ) ;
433
+ expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( false ) ;
434
+ } ) ;
423
435
} ) ;
424
436
425
437
it ( 'control with is-open' , function ( ) {
0 commit comments