From 63345bbd3b3fea4919bbe8947fa018c8d5d7417d Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Thu, 5 Feb 2015 17:34:37 -0800 Subject: [PATCH] [Plot] Add test for resource release Add test to detect plot failing to release its subscriptions, which causes WTD-840. --- platform/features/plot/test/PlotControllerSpec.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/platform/features/plot/test/PlotControllerSpec.js b/platform/features/plot/test/PlotControllerSpec.js index a8523502ee..865ad2c335 100644 --- a/platform/features/plot/test/PlotControllerSpec.js +++ b/platform/features/plot/test/PlotControllerSpec.js @@ -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(); + }); }); } ); \ No newline at end of file