@@ -224,11 +224,29 @@ describe('dropdownToggle', function() {
224
224
expect ( $document . find ( '#dropdown-menu' ) . parent ( ) [ 0 ] ) . toBe ( $document . find ( 'body' ) [ 0 ] ) ;
225
225
} ) ;
226
226
227
+ it ( 'adds the dropdown class to the body' , function ( ) {
228
+ expect ( $document . find ( 'body' ) . hasClass ( 'dropdown' ) ) . toBe ( true ) ;
229
+ } ) ;
230
+
227
231
it ( 'removes the menu when the dropdown is removed' , function ( ) {
228
232
element . remove ( ) ;
229
233
$rootScope . $digest ( ) ;
230
234
expect ( $document . find ( '#dropdown-menu' ) . length ) . toEqual ( 0 ) ;
231
235
} ) ;
236
+
237
+ it ( 'toggles the open class on body' , function ( ) {
238
+ var body = $document . find ( 'body' ) ;
239
+
240
+ expect ( body . hasClass ( 'open' ) ) . toBe ( false ) ;
241
+
242
+ element . find ( '[dropdown-toggle]' ) . click ( ) ;
243
+
244
+ expect ( body . hasClass ( 'open' ) ) . toBe ( true ) ;
245
+
246
+ element . find ( '[dropdown-toggle]' ) . click ( ) ;
247
+
248
+ expect ( body . hasClass ( 'open' ) ) . toBe ( false ) ;
249
+ } ) ;
232
250
} ) ;
233
251
234
252
describe ( 'integration with $location URL rewriting' , function ( ) {
@@ -437,11 +455,12 @@ describe('dropdownToggle', function() {
437
455
it ( 'should work with dropdown-append-to-body' , function ( ) {
438
456
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 ) ;
439
457
clickDropdownToggle ( ) ;
440
- expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( true ) ;
458
+ var body = $document . find ( 'body' ) ;
459
+ expect ( body . hasClass ( dropdownConfig . openClass ) ) . toBe ( true ) ;
441
460
$document . find ( '#dropdown-menu' ) . find ( 'li' ) . eq ( 0 ) . trigger ( 'click' ) ;
442
- expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( true ) ;
461
+ expect ( body . hasClass ( dropdownConfig . openClass ) ) . toBe ( true ) ;
443
462
$document . click ( ) ;
444
- expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( false ) ;
463
+ expect ( body . hasClass ( dropdownConfig . openClass ) ) . toBe ( false ) ;
445
464
} ) ;
446
465
} ) ;
447
466
@@ -657,7 +676,7 @@ describe('dropdownToggle', function() {
657
676
658
677
triggerKeyDown ( element , 40 ) ;
659
678
660
- expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( true ) ;
679
+ expect ( $document . find ( 'body' ) . hasClass ( dropdownConfig . openClass ) ) . toBe ( true ) ;
661
680
var focusEl = $document . find ( 'ul' ) . eq ( 0 ) . find ( 'a' ) ;
662
681
expect ( isFocused ( focusEl ) ) . toBe ( true ) ;
663
682
} ) ;
@@ -667,7 +686,7 @@ describe('dropdownToggle', function() {
667
686
triggerKeyDown ( element , 40 ) ;
668
687
triggerKeyDown ( element , 40 ) ;
669
688
670
- expect ( element . hasClass ( dropdownConfig . openClass ) ) . toBe ( true ) ;
689
+ expect ( $document . find ( 'body' ) . hasClass ( dropdownConfig . openClass ) ) . toBe ( true ) ;
671
690
var elem1 = $document . find ( 'ul' ) ;
672
691
var elem2 = elem1 . find ( 'a' ) ;
673
692
var focusEl = $document . find ( 'ul' ) . eq ( 0 ) . find ( 'a' ) . eq ( 1 ) ;
0 commit comments