2015-06-18 03:35:17 +00:00
|
|
|
/*****************************************************************************
|
2017-04-05 21:35:12 +00:00
|
|
|
* Open MCT, Copyright (c) 2014-2017, United States Government
|
2015-06-18 03:35:17 +00:00
|
|
|
* as represented by the Administrator of the National Aeronautics and Space
|
|
|
|
* Administration. All rights reserved.
|
|
|
|
*
|
2016-07-12 23:21:58 +00:00
|
|
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
2015-06-18 03:35:17 +00:00
|
|
|
* "License"); you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*
|
2016-07-12 23:21:58 +00:00
|
|
|
* Open MCT includes source code licensed under additional open source
|
2015-06-18 03:35:17 +00:00
|
|
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
|
|
|
* this source code distribution or the Licensing information page available
|
|
|
|
* at runtime from the About dialog for additional information.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
define(
|
|
|
|
["../../src/controllers/ImageryController"],
|
|
|
|
function (ImageryController) {
|
|
|
|
|
|
|
|
describe("The Imagery controller", function () {
|
2017-05-23 01:30:01 +00:00
|
|
|
var $scope,
|
|
|
|
openmct,
|
|
|
|
oldDomainObject,
|
|
|
|
newDomainObject,
|
|
|
|
unsubscribe,
|
|
|
|
callback,
|
2015-06-18 04:15:17 +00:00
|
|
|
controller;
|
|
|
|
|
|
|
|
beforeEach(function () {
|
2017-05-23 01:30:01 +00:00
|
|
|
$scope = jasmine.createSpyObj('$scope', ['$on', '$watch']);
|
|
|
|
oldDomainObject = jasmine.createSpyObj(
|
2015-06-18 04:15:17 +00:00
|
|
|
'domainObject',
|
2017-05-23 01:30:01 +00:00
|
|
|
['getId']
|
2015-06-18 04:15:17 +00:00
|
|
|
);
|
|
|
|
|
2017-05-23 01:30:01 +00:00
|
|
|
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));
|
2015-06-18 04:15:17 +00:00
|
|
|
|
|
|
|
controller = new ImageryController(
|
2017-05-23 01:30:01 +00:00
|
|
|
$scope,
|
|
|
|
openmct
|
2015-06-18 04:15:17 +00:00
|
|
|
);
|
2017-05-23 01:30:01 +00:00
|
|
|
|
2015-06-18 04:15:17 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("unsubscribes when scope is destroyed", function () {
|
|
|
|
expect(mockHandle.unsubscribe).not.toHaveBeenCalled();
|
|
|
|
|
|
|
|
// Find the $destroy listener and call it
|
|
|
|
mockScope.$on.calls.forEach(function (call) {
|
|
|
|
if (call.args[0] === '$destroy') {
|
|
|
|
call.args[1]();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
expect(mockHandle.unsubscribe).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("exposes the latest telemetry values", function () {
|
|
|
|
// 06/18/2015 4:04am UTC
|
|
|
|
var testTimestamp = 1434600258123,
|
|
|
|
testUrl = "some/url",
|
|
|
|
nextTimestamp = 1434600259456, // 4:05.456
|
|
|
|
nextUrl = "some/other/url";
|
|
|
|
|
|
|
|
mockHandle.getDomainValue.andReturn(testTimestamp);
|
|
|
|
mockHandle.getRangeValue.andReturn(testUrl);
|
|
|
|
|
|
|
|
// Call the subscription listener
|
|
|
|
mockTelemetryHandler.handle.mostRecentCall.args[1]();
|
|
|
|
|
|
|
|
expect(controller.getTime()).toEqual("04:04:18.123");
|
|
|
|
expect(controller.getDate()).toEqual("2015-06-18");
|
|
|
|
expect(controller.getZone()).toEqual("UTC");
|
|
|
|
expect(controller.getImageUrl()).toEqual(testUrl);
|
|
|
|
|
|
|
|
mockHandle.getDomainValue.andReturn(nextTimestamp);
|
|
|
|
mockHandle.getRangeValue.andReturn(nextUrl);
|
|
|
|
mockTelemetryHandler.handle.mostRecentCall.args[1]();
|
|
|
|
|
|
|
|
expect(controller.getTime()).toEqual("04:04:19.456");
|
|
|
|
expect(controller.getDate()).toEqual("2015-06-18");
|
|
|
|
expect(controller.getZone()).toEqual("UTC");
|
|
|
|
expect(controller.getImageUrl()).toEqual(nextUrl);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("allows updates to be paused", function () {
|
|
|
|
// 06/18/2015 4:04am UTC
|
|
|
|
var testTimestamp = 1434600258123,
|
|
|
|
testUrl = "some/url",
|
|
|
|
nextTimestamp = 1434600259456, // 4:05.456
|
|
|
|
nextUrl = "some/other/url";
|
|
|
|
|
|
|
|
// As above, but pause in between. Expect details
|
|
|
|
// not to change this time
|
|
|
|
|
|
|
|
mockHandle.getDomainValue.andReturn(testTimestamp);
|
|
|
|
mockHandle.getRangeValue.andReturn(testUrl);
|
|
|
|
|
|
|
|
// Call the subscription listener
|
|
|
|
mockTelemetryHandler.handle.mostRecentCall.args[1]();
|
|
|
|
|
|
|
|
expect(controller.getTime()).toEqual("04:04:18.123");
|
|
|
|
expect(controller.getDate()).toEqual("2015-06-18");
|
|
|
|
expect(controller.getZone()).toEqual("UTC");
|
|
|
|
expect(controller.getImageUrl()).toEqual(testUrl);
|
|
|
|
|
|
|
|
expect(controller.paused()).toBeFalsy();
|
|
|
|
controller.paused(true); // Pause!
|
|
|
|
expect(controller.paused()).toBeTruthy();
|
|
|
|
|
|
|
|
mockHandle.getDomainValue.andReturn(nextTimestamp);
|
|
|
|
mockHandle.getRangeValue.andReturn(nextUrl);
|
|
|
|
mockTelemetryHandler.handle.mostRecentCall.args[1]();
|
|
|
|
|
|
|
|
expect(controller.getTime()).toEqual("04:04:18.123");
|
|
|
|
expect(controller.getDate()).toEqual("2015-06-18");
|
|
|
|
expect(controller.getZone()).toEqual("UTC");
|
|
|
|
expect(controller.getImageUrl()).toEqual(testUrl);
|
|
|
|
});
|
2015-06-18 03:35:17 +00:00
|
|
|
|
2015-06-22 20:34:02 +00:00
|
|
|
it("initially shows an empty string for date/time", function () {
|
|
|
|
// Call the subscription listener while domain/range
|
|
|
|
// values are still undefined
|
|
|
|
mockHandle.getDomainValue.andReturn(undefined);
|
|
|
|
mockHandle.getRangeValue.andReturn(undefined);
|
|
|
|
mockTelemetryHandler.handle.mostRecentCall.args[1]();
|
|
|
|
|
|
|
|
// Should have empty strings for date/time/zone
|
|
|
|
expect(controller.getTime()).toEqual("");
|
|
|
|
expect(controller.getDate()).toEqual("");
|
|
|
|
expect(controller.getZone()).toEqual("");
|
|
|
|
expect(controller.getImageUrl()).toBeUndefined();
|
|
|
|
});
|
2015-06-18 03:35:17 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|