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

Commit

Permalink
fix(calendar): ensure all instances are removed from DOM after tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jelbourn committed Aug 19, 2015
1 parent 8d6134a commit e314072
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/components/datepicker/calendar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ describe('md-calendar', function() {
var ngElement, element, scope, pageScope, controller, $animate, $compile, $$rAF;
var $rootScope, dateLocale, $mdUtil, keyCodes, dateUtil;

// List of calendar elements added to the DOM so we can remove them after every test.
var attachedCalendarElements = [];

/**
* To apply a change in the date, a scope $apply() AND a manual triggering of animation
* callbacks is necessary.
Expand Down Expand Up @@ -64,6 +67,7 @@ describe('md-calendar', function() {
var attachedElement = angular.element(template);
document.body.appendChild(attachedElement[0]);
var newElement = $compile(attachedElement)(directiveScope);
attachedCalendarElements.push(newElement);
applyDateChange();
return newElement;
}
Expand Down Expand Up @@ -136,7 +140,10 @@ describe('md-calendar', function() {
}));

afterEach(function() {
ngElement.remove();
attachedCalendarElements.forEach(function(element) {
element.remove();
});
attachedCalendarElements = [];
});

describe('ngModel binding', function() {
Expand Down

0 comments on commit e314072

Please sign in to comment.