Fix cleanup of resize events

This commit is contained in:
Joe Fiorini
2015-01-29 14:20:39 -05:00
parent f1f15f1670
commit e28869c63d
3 changed files with 29 additions and 7 deletions

View File

@@ -1,10 +1,13 @@
describe('Job Status Graph Directive', function() {
var element, scope, httpBackend;
var resizeHandler = sinon.spy();
beforeEach(module('Tower'));
beforeEach(module(function($provide) {
$provide.value('LoadBasePaths', angular.noop);
$provide.value('adjustGraphSize', resizeHandler);
}));
beforeEach(inject(function($rootScope, $compile, $httpBackend) {
@@ -36,8 +39,9 @@ describe('Job Status Graph Directive', function() {
}));
afterEach(function() {
httpBackend.verifyNoOutstandingExpectation();
httpBackend.verifyNoOutstandingRequest();
element.trigger('$destroy');
httpBackend.verifyNoOutstandingExpectation();
httpBackend.verifyNoOutstandingRequest();
});
function filterDataSeries(key, data) {
@@ -68,5 +72,17 @@ describe('Job Status Graph Directive', function() {
{x: 5, y: 0, series: 1}]);
});
it('cleans up external bindings', function() {
element.trigger('$destroy');
resizeHandler.reset();
inject(['$window', function($window) {
angular.element($window).trigger('resize');
}]);
expect(resizeHandler).not.to.have.been.called;
});
});