@@ -9,6 +9,10 @@ describe('dropdownToggle', function() {
9
9
$document = _$document_ ;
10
10
} ) ) ;
11
11
12
+ afterEach ( function ( ) {
13
+ element . remove ( ) ;
14
+ } ) ;
15
+
12
16
var clickDropdownToggle = function ( elm ) {
13
17
elm = elm || element ;
14
18
elm . find ( 'a[dropdown-toggle]' ) . click ( ) ;
@@ -50,7 +54,6 @@ describe('dropdownToggle', function() {
50
54
var optionEl = element . find ( 'ul > li' ) . eq ( 0 ) . find ( 'a' ) . eq ( 0 ) ;
51
55
optionEl . click ( ) ;
52
56
expect ( element . hasClass ( 'open' ) ) . toBe ( false ) ;
53
- element . remove ( ) ;
54
57
} ) ;
55
58
56
59
it ( 'should close on document click' , function ( ) {
@@ -66,7 +69,6 @@ describe('dropdownToggle', function() {
66
69
triggerKeyDown ( $document , 27 ) ;
67
70
expect ( element . hasClass ( 'open' ) ) . toBe ( false ) ;
68
71
expect ( isFocused ( element . find ( 'a' ) ) ) . toBe ( true ) ;
69
- element . remove ( ) ;
70
72
} ) ;
71
73
72
74
it ( 'should not close on backspace key' , function ( ) {
@@ -192,6 +194,12 @@ describe('dropdownToggle', function() {
192
194
it ( 'adds the menu to the body' , function ( ) {
193
195
expect ( $document . find ( '#dropdown-menu' ) . parent ( ) [ 0 ] ) . toBe ( $document . find ( 'body' ) [ 0 ] ) ;
194
196
} ) ;
197
+
198
+ it ( 'removes the menu when the dropdown is removed' , function ( ) {
199
+ element . remove ( ) ;
200
+ $rootScope . $digest ( ) ;
201
+ expect ( $document . find ( '#dropdown-menu' ) . length ) . toEqual ( 0 ) ;
202
+ } ) ;
195
203
} ) ;
196
204
197
205
describe ( 'integration with $location URL rewriting' , function ( ) {
@@ -270,7 +278,6 @@ describe('dropdownToggle', function() {
270
278
$rootScope . isopen = true ;
271
279
$rootScope . $digest ( ) ;
272
280
expect ( isFocused ( element . find ( 'a' ) ) ) . toBe ( true ) ;
273
- element . remove ( ) ;
274
281
} ) ;
275
282
} ) ;
276
283
@@ -410,7 +417,6 @@ describe('dropdownToggle', function() {
410
417
triggerKeyDown ( $document , 27 ) ;
411
418
expect ( element . hasClass ( 'open' ) ) . toBe ( false ) ;
412
419
expect ( isFocused ( element . find ( 'a' ) ) ) . toBe ( true ) ;
413
- element . remove ( ) ;
414
420
} ) ;
415
421
416
422
it ( 'should close anyway if another dropdown is opened' , function ( ) {
0 commit comments