Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit e314072

Browse files
committed
fix(calendar): ensure all instances are removed from DOM after tests.
1 parent 8d6134a commit e314072

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/components/datepicker/calendar.spec.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ describe('md-calendar', function() {
88
var ngElement, element, scope, pageScope, controller, $animate, $compile, $$rAF;
99
var $rootScope, dateLocale, $mdUtil, keyCodes, dateUtil;
1010

11+
// List of calendar elements added to the DOM so we can remove them after every test.
12+
var attachedCalendarElements = [];
13+
1114
/**
1215
* To apply a change in the date, a scope $apply() AND a manual triggering of animation
1316
* callbacks is necessary.
@@ -64,6 +67,7 @@ describe('md-calendar', function() {
6467
var attachedElement = angular.element(template);
6568
document.body.appendChild(attachedElement[0]);
6669
var newElement = $compile(attachedElement)(directiveScope);
70+
attachedCalendarElements.push(newElement);
6771
applyDateChange();
6872
return newElement;
6973
}
@@ -136,7 +140,10 @@ describe('md-calendar', function() {
136140
}));
137141

138142
afterEach(function() {
139-
ngElement.remove();
143+
attachedCalendarElements.forEach(function(element) {
144+
element.remove();
145+
});
146+
attachedCalendarElements = [];
140147
});
141148

142149
describe('ngModel binding', function() {

0 commit comments

Comments
 (0)