mirror of
https://github.com/nasa/openmct.git
synced 2025-01-17 10:20:27 +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) {
|
capabilities.telemetry = function (domainObject) {
|
||||||
return new ConductorCapabilityDecorator(
|
return new ConductorCapabilityDecorator(
|
||||||
conductorService.getConductor(),
|
conductorService.getConductor(),
|
||||||
new TelemetryCapability(domainObject),
|
new TelemetryCapability(domainObject)
|
||||||
domainObject
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,8 @@ define(
|
|||||||
function () {
|
function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function ConductorTelemetryCapability(timeConductor, telemetryCapability, domainObject) {
|
function ConductorTelemetryCapability(timeConductor, telemetryCapability) {
|
||||||
|
this.timeConductor = timeConductor;
|
||||||
this.wrappedCapability = telemetryCapability;
|
this.wrappedCapability = telemetryCapability;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,9 +43,6 @@ define(
|
|||||||
};
|
};
|
||||||
|
|
||||||
ConductorTelemetryCapability.prototype.subscribe = function (callback, request) {
|
ConductorTelemetryCapability.prototype.subscribe = function (callback, request) {
|
||||||
request = request || {};
|
|
||||||
request.start = this.timeConductor.queryStart();
|
|
||||||
request.end = this.timeConductor.queryEnd();
|
|
||||||
return this.wrappedCapability.subscribe(callback, request);
|
return this.wrappedCapability.subscribe(callback, request);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -30,6 +30,71 @@ define(
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
describe("ConductorTelemetryCapability", function () {
|
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