Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 6247783

Browse files
committed
feat(dropdown): Fix dropdown tests, add cleanup test
1 parent 9a5bd0e commit 6247783

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Diff for: src/dropdown/test/dropdown.spec.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ describe('dropdownToggle', function() {
99
$document = _$document_;
1010
}));
1111

12+
afterEach(function() {
13+
element.remove();
14+
});
15+
1216
var clickDropdownToggle = function(elm) {
1317
elm = elm || element;
1418
elm.find('a[dropdown-toggle]').click();
@@ -50,7 +54,6 @@ describe('dropdownToggle', function() {
5054
var optionEl = element.find('ul > li').eq(0).find('a').eq(0);
5155
optionEl.click();
5256
expect(element.hasClass('open')).toBe(false);
53-
element.remove();
5457
});
5558

5659
it('should close on document click', function() {
@@ -66,7 +69,6 @@ describe('dropdownToggle', function() {
6669
triggerKeyDown($document, 27);
6770
expect(element.hasClass('open')).toBe(false);
6871
expect(isFocused(element.find('a'))).toBe(true);
69-
element.remove();
7072
});
7173

7274
it('should not close on backspace key', function() {
@@ -192,6 +194,12 @@ describe('dropdownToggle', function() {
192194
it('adds the menu to the body', function() {
193195
expect($document.find('#dropdown-menu').parent()[0]).toBe($document.find('body')[0]);
194196
});
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+
});
195203
});
196204

197205
describe('integration with $location URL rewriting', function() {
@@ -270,7 +278,6 @@ describe('dropdownToggle', function() {
270278
$rootScope.isopen = true;
271279
$rootScope.$digest();
272280
expect(isFocused(element.find('a'))).toBe(true);
273-
element.remove();
274281
});
275282
});
276283

@@ -410,7 +417,6 @@ describe('dropdownToggle', function() {
410417
triggerKeyDown($document, 27);
411418
expect(element.hasClass('open')).toBe(false);
412419
expect(isFocused(element.find('a'))).toBe(true);
413-
element.remove();
414420
});
415421

416422
it('should close anyway if another dropdown is opened', function() {

0 commit comments

Comments
 (0)