[Plot] Add test for resource release

Add test to detect plot failing to release its subscriptions,
which causes WTD-840.
This commit is contained in:
Victor Woeltjen 2015-02-05 17:34:37 -08:00
parent 4ac25ab093
commit 63345bbd3b

View File

@ -173,6 +173,19 @@ define(
// Placeholder; need to support requesting telemetry
expect(controller.isRequestPending()).toBeFalsy();
});
it("unsubscribes when destroyed", function () {
// Make an object available
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
// Make sure $destroy is what's listened for
expect(mockScope.$on.mostRecentCall.args[0]).toEqual('$destroy');
// Also verify precondition
expect(mockSubscription.unsubscribe).not.toHaveBeenCalled();
// Destroy the scope
mockScope.$on.mostRecentCall.args[1]();
// Should have unsubscribed
expect(mockSubscription.unsubscribe).toHaveBeenCalled();
});
});
}
);