mirror of
https://github.com/nasa/openmct.git
synced 2025-06-11 11:51:40 +00:00
Merge remote-tracking branch 'origin/open840' into open-master
This commit is contained in:
commit
471e86bd6d
@ -113,8 +113,20 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Release the current subscription (called when scope is destroyed)
|
||||||
|
function releaseSubscription() {
|
||||||
|
if (subscription) {
|
||||||
|
subscription.unsubscribe();
|
||||||
|
subscription = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subscribe to telemetry when a domain object becomes available
|
||||||
$scope.$watch('domainObject', subscribe);
|
$scope.$watch('domainObject', subscribe);
|
||||||
|
|
||||||
|
// Unsubscribe when the plot is destroyed
|
||||||
|
$scope.$on("$destroy", releaseSubscription);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
/**
|
/**
|
||||||
* Get the color (as a style-friendly string) to use
|
* Get the color (as a style-friendly string) to use
|
||||||
|
@ -173,6 +173,19 @@ define(
|
|||||||
// Placeholder; need to support requesting telemetry
|
// Placeholder; need to support requesting telemetry
|
||||||
expect(controller.isRequestPending()).toBeFalsy();
|
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();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
Loading…
x
Reference in New Issue
Block a user