WIP refactor for new telem api

This commit is contained in:
Pete Richards
2017-05-22 18:30:01 -07:00
parent 26a7fee869
commit b60eb6d6ae
6 changed files with 109 additions and 122 deletions

View File

@@ -25,48 +25,45 @@ define(
function (ImageryController) {
describe("The Imagery controller", function () {
var mockScope,
mockTelemetryHandler,
mockHandle,
mockDomainObject,
var $scope,
openmct,
oldDomainObject,
newDomainObject,
unsubscribe,
callback,
controller;
function invokeWatch(expr, value) {
mockScope.$watch.calls.forEach(function (call) {
if (call.args[0] === expr) {
call.args[1](value);
}
});
}
beforeEach(function () {
mockScope = jasmine.createSpyObj('$scope', ['$on', '$watch']);
mockTelemetryHandler = jasmine.createSpyObj(
'telemetryHandler',
['handle']
);
mockHandle = jasmine.createSpyObj(
'handle',
[
'getDomainValue',
'getRangeValue',
'getTelemetryObjects',
'unsubscribe'
]
);
mockDomainObject = jasmine.createSpyObj(
$scope = jasmine.createSpyObj('$scope', ['$on', '$watch']);
oldDomainObject = jasmine.createSpyObj(
'domainObject',
['getId', 'getModel', 'getCapability']
['getId']
);
mockTelemetryHandler.handle.andReturn(mockHandle);
mockHandle.getTelemetryObjects.andReturn([mockDomainObject]);
oldDomainObject.getId.andReturn('testID');
openmct = {
objects: jasmine.createSpyObj('objectAPI', [
'get'
]),
time: jasmine.createSpyObj('timeAPI', [
'timeSystem'
]),
telemetry: jasmine.createSpyObj('telemetryAPI', [
'subscribe'
]);
};
unsubscribe = jasmine.createSpy('unsubscribe');
openmct.telemetry.subscribe.andReturn(unsubcribe);
openmct.time.timeSystem.andReturn({
key: 'testKey'
});
openmct.objects.get.andReturn(Promise.resolve(newDomainObject));
controller = new ImageryController(
mockScope,
mockTelemetryHandler
$scope,
openmct
);
invokeWatch('domainObject', mockDomainObject);
});
it("unsubscribes when scope is destroyed", function () {