mirror of
https://github.com/nasa/openmct.git
synced 2024-12-30 01:48:51 +00:00
[Time Controller] Test conductor's telemetry capability
WTD-1515
This commit is contained in:
parent
9ccd0b9188
commit
8a76c3a425
@ -40,8 +40,7 @@ define(
|
||||
capabilities.telemetry = function (domainObject) {
|
||||
return new ConductorCapabilityDecorator(
|
||||
conductorService.getConductor(),
|
||||
new TelemetryCapability(domainObject),
|
||||
domainObject
|
||||
new TelemetryCapability(domainObject)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
@ -26,7 +26,8 @@ define(
|
||||
function () {
|
||||
'use strict';
|
||||
|
||||
function ConductorTelemetryCapability(timeConductor, telemetryCapability, domainObject) {
|
||||
function ConductorTelemetryCapability(timeConductor, telemetryCapability) {
|
||||
this.timeConductor = timeConductor;
|
||||
this.wrappedCapability = telemetryCapability;
|
||||
}
|
||||
|
||||
@ -42,9 +43,6 @@ define(
|
||||
};
|
||||
|
||||
ConductorTelemetryCapability.prototype.subscribe = function (callback, request) {
|
||||
request = request || {};
|
||||
request.start = this.timeConductor.queryStart();
|
||||
request.end = this.timeConductor.queryEnd();
|
||||
return this.wrappedCapability.subscribe(callback, request);
|
||||
};
|
||||
|
||||
|
@ -30,6 +30,71 @@ define(
|
||||
"use strict";
|
||||
|
||||
describe("ConductorTelemetryCapability", function () {
|
||||
var mockConductor,
|
||||
mockTelemetryCapability,
|
||||
mockUnsubscribe,
|
||||
testMetadata,
|
||||
testStartTime,
|
||||
testEndTime,
|
||||
conductorTelemetryCapability;
|
||||
|
||||
beforeEach(function () {
|
||||
mockConductor = jasmine.createSpyObj(
|
||||
'timeConductor',
|
||||
[
|
||||
'queryStart',
|
||||
'queryEnd',
|
||||
'displayStart',
|
||||
'displayEnd'
|
||||
]
|
||||
);
|
||||
mockTelemetryCapability = jasmine.createSpyObj(
|
||||
'telemetry',
|
||||
[ 'getMetadata', 'requestData', 'subscribe' ]
|
||||
);
|
||||
mockUnsubscribe = jasmine.createSpy('unsubscribe');
|
||||
|
||||
testStartTime = 42;
|
||||
testEndTime = 12321;
|
||||
testMetadata = { someKey: 'some value' };
|
||||
mockTelemetryCapability.getMetadata.andReturn(testMetadata);
|
||||
mockTelemetryCapability.subscribe.andReturn(mockUnsubscribe);
|
||||
mockConductor.queryStart.andReturn(testStartTime);
|
||||
mockConductor.queryEnd.andReturn(testEndTime);
|
||||
|
||||
conductorTelemetryCapability = new ConductorTelemetryCapability(
|
||||
mockConductor,
|
||||
mockTelemetryCapability
|
||||
);
|
||||
});
|
||||
|
||||
it("simply delegates getMetadata calls", function () {
|
||||
expect(conductorTelemetryCapability.getMetadata())
|
||||
.toBe(testMetadata);
|
||||
});
|
||||
|
||||
it("adds start/end times to requests", function () {
|
||||
conductorTelemetryCapability
|
||||
.requestData({ someKey: "some value" });
|
||||
expect(mockTelemetryCapability.requestData).toHaveBeenCalledWith({
|
||||
someKey: "some value",
|
||||
start: testStartTime,
|
||||
end: testEndTime
|
||||
});
|
||||
});
|
||||
|
||||
it("simply delegates subscribe calls", function () {
|
||||
var mockCallback = jasmine.createSpy('callback'),
|
||||
testRequest = { someKey: "some value" };
|
||||
expect(conductorTelemetryCapability.subscribe(
|
||||
mockCallback,
|
||||
testRequest
|
||||
)).toBe(mockUnsubscribe);
|
||||
expect(mockTelemetryCapability.subscribe).toHaveBeenCalledWith(
|
||||
mockCallback,
|
||||
{ someKey: "some value" }
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user