[Time Controller] Test conductor's telemetry capability

WTD-1515
This commit is contained in:
Victor Woeltjen 2015-09-04 10:57:50 -07:00
parent 9ccd0b9188
commit 8a76c3a425
3 changed files with 68 additions and 6 deletions

View File

@ -40,8 +40,7 @@ define(
capabilities.telemetry = function (domainObject) {
return new ConductorCapabilityDecorator(
conductorService.getConductor(),
new TelemetryCapability(domainObject),
domainObject
new TelemetryCapability(domainObject)
);
};
}

View File

@ -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);
};

View File

@ -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" }
);
});
});
}