mirror of
https://github.com/nasa/openmct.git
synced 2025-06-17 22:58:14 +00:00
[Plot] Update plot controller spec
Update plot controller spec to reflect changes introduced for WTD-751 and WTD-784.
This commit is contained in:
@ -85,7 +85,9 @@ define(
|
|||||||
|
|
||||||
// Handle new telemetry data in this plot
|
// Handle new telemetry data in this plot
|
||||||
function updateValues() {
|
function updateValues() {
|
||||||
setupModes(subscription.getTelemetryObjects());
|
if (subscription) {
|
||||||
|
setupModes(subscription.getTelemetryObjects());
|
||||||
|
}
|
||||||
if (updater) {
|
if (updater) {
|
||||||
updater.update();
|
updater.update();
|
||||||
modeOptions.getModeHandler().plotTelemetry(updater);
|
modeOptions.getModeHandler().plotTelemetry(updater);
|
||||||
@ -105,6 +107,7 @@ define(
|
|||||||
true // Lossless
|
true // Lossless
|
||||||
);
|
);
|
||||||
if (subscription) {
|
if (subscription) {
|
||||||
|
setupModes(subscription.getTelemetryObjects());
|
||||||
setupAxes(subscription.getMetadata());
|
setupAxes(subscription.getMetadata());
|
||||||
recreateUpdater();
|
recreateUpdater();
|
||||||
}
|
}
|
||||||
@ -183,6 +186,8 @@ define(
|
|||||||
* Check if a request is pending (to show the wait spinner)
|
* Check if a request is pending (to show the wait spinner)
|
||||||
*/
|
*/
|
||||||
isRequestPending: function () {
|
isRequestPending: function () {
|
||||||
|
// Placeholder; this should reflect request state
|
||||||
|
// when requesting historical telemetry
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -12,11 +12,10 @@ define(
|
|||||||
var mockScope,
|
var mockScope,
|
||||||
mockFormatter,
|
mockFormatter,
|
||||||
mockSubscriber,
|
mockSubscriber,
|
||||||
mockData,
|
mockSubscription,
|
||||||
mockDomainObject,
|
mockDomainObject,
|
||||||
controller;
|
controller;
|
||||||
|
|
||||||
function echo(i) { return i; }
|
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockScope = jasmine.createSpyObj(
|
mockScope = jasmine.createSpyObj(
|
||||||
@ -27,10 +26,6 @@ define(
|
|||||||
"formatter",
|
"formatter",
|
||||||
[ "formatDomainValue", "formatRangeValue" ]
|
[ "formatDomainValue", "formatRangeValue" ]
|
||||||
);
|
);
|
||||||
mockData = jasmine.createSpyObj(
|
|
||||||
"data",
|
|
||||||
[ "getPointCount", "getDomainValue", "getRangeValue" ]
|
|
||||||
);
|
|
||||||
mockDomainObject = jasmine.createSpyObj(
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
"domainObject",
|
"domainObject",
|
||||||
[ "getId", "getModel", "getCapability" ]
|
[ "getId", "getModel", "getCapability" ]
|
||||||
@ -39,10 +34,22 @@ define(
|
|||||||
"telemetrySubscriber",
|
"telemetrySubscriber",
|
||||||
["subscribe"]
|
["subscribe"]
|
||||||
);
|
);
|
||||||
|
mockSubscription = jasmine.createSpyObj(
|
||||||
|
"subscription",
|
||||||
|
[
|
||||||
|
"unsubscribe",
|
||||||
|
"getTelemetryObjects",
|
||||||
|
"getMetadata",
|
||||||
|
"getDomainValue",
|
||||||
|
"getRangeValue"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
mockData.getPointCount.andReturn(2);
|
mockSubscriber.subscribe.andReturn(mockSubscription);
|
||||||
mockData.getDomainValue.andCallFake(echo);
|
mockSubscription.getTelemetryObjects.andReturn([mockDomainObject]);
|
||||||
mockData.getRangeValue.andCallFake(echo);
|
mockSubscription.getMetadata.andReturn([{}]);
|
||||||
|
mockSubscription.getDomainValue.andReturn(123);
|
||||||
|
mockSubscription.getRangeValue.andReturn(42);
|
||||||
|
|
||||||
controller = new PlotController(mockScope, mockFormatter, mockSubscriber);
|
controller = new PlotController(mockScope, mockFormatter, mockSubscriber);
|
||||||
});
|
});
|
||||||
@ -57,7 +64,24 @@ define(
|
|||||||
.not.toEqual(controller.getColor(1));
|
.not.toEqual(controller.getColor(1));
|
||||||
});
|
});
|
||||||
|
|
||||||
xit("draws lines when data becomes available", function () {
|
it("subscribes to telemetry when a domain object appears in scope", function () {
|
||||||
|
// Make sure we're using the right watch here
|
||||||
|
expect(mockScope.$watch.mostRecentCall.args[0])
|
||||||
|
.toEqual("domainObject");
|
||||||
|
// Make an object available
|
||||||
|
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||||
|
// Should have subscribed
|
||||||
|
expect(mockSubscriber.subscribe).toHaveBeenCalledWith(
|
||||||
|
mockDomainObject,
|
||||||
|
jasmine.any(Function),
|
||||||
|
true // Lossless
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("draws lines when data becomes available", function () {
|
||||||
|
// Make an object available
|
||||||
|
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||||
|
|
||||||
// Verify precondition
|
// Verify precondition
|
||||||
controller.getSubPlots().forEach(function (subplot) {
|
controller.getSubPlots().forEach(function (subplot) {
|
||||||
expect(subplot.getDrawingObject().lines)
|
expect(subplot.getDrawingObject().lines)
|
||||||
@ -65,11 +89,10 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Make sure there actually are subplots being verified
|
// Make sure there actually are subplots being verified
|
||||||
expect(controller.getSubPlots().length > 0)
|
expect(controller.getSubPlots().length > 0).toBeTruthy();
|
||||||
.toBeTruthy();
|
|
||||||
|
|
||||||
// Broadcast data
|
// Broadcast data
|
||||||
mockScope.$on.mostRecentCall.args[1]();
|
mockSubscriber.subscribe.mostRecentCall.args[1]();
|
||||||
|
|
||||||
controller.getSubPlots().forEach(function (subplot) {
|
controller.getSubPlots().forEach(function (subplot) {
|
||||||
expect(subplot.getDrawingObject().lines)
|
expect(subplot.getDrawingObject().lines)
|
||||||
@ -77,27 +100,39 @@ define(
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("unsubscribes when domain object changes", function () {
|
||||||
|
// Make an object available
|
||||||
|
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||||
|
// Verify precondition - shouldn't unsubscribe yet
|
||||||
|
expect(mockSubscription.unsubscribe).not.toHaveBeenCalled();
|
||||||
|
// Remove the domain object
|
||||||
|
mockScope.$watch.mostRecentCall.args[1](undefined);
|
||||||
|
// Should have unsubscribed
|
||||||
|
expect(mockSubscription.unsubscribe).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
xit("changes modes depending on number of objects", function () {
|
|
||||||
var expectedWatch = "telemetry.getTelemetryObjects()",
|
|
||||||
watchFunction;
|
|
||||||
|
|
||||||
// Find the watch for telemetry objects, which
|
it("changes modes depending on number of objects", function () {
|
||||||
// should change plot mode options
|
// Act like one object is available
|
||||||
mockScope.$watch.calls.forEach(function (call) {
|
mockSubscription.getTelemetryObjects.andReturn([
|
||||||
if (call.args[0] === expectedWatch) {
|
mockDomainObject
|
||||||
watchFunction = call.args[1];
|
]);
|
||||||
}
|
|
||||||
});
|
// Make an object available
|
||||||
|
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||||
|
|
||||||
watchFunction([mockDomainObject]);
|
|
||||||
expect(controller.getModeOptions().length).toEqual(1);
|
expect(controller.getModeOptions().length).toEqual(1);
|
||||||
|
|
||||||
watchFunction([
|
// Act like one object is available
|
||||||
|
mockSubscription.getTelemetryObjects.andReturn([
|
||||||
mockDomainObject,
|
mockDomainObject,
|
||||||
mockDomainObject,
|
mockDomainObject,
|
||||||
mockDomainObject
|
mockDomainObject
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// Make an object available
|
||||||
|
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||||
|
|
||||||
expect(controller.getModeOptions().length).toEqual(2);
|
expect(controller.getModeOptions().length).toEqual(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -113,7 +148,7 @@ define(
|
|||||||
.toEqual(jasmine.any(String));
|
.toEqual(jasmine.any(String));
|
||||||
});
|
});
|
||||||
|
|
||||||
xit("allows plot mode to be changed", function () {
|
it("allows plot mode to be changed", function () {
|
||||||
expect(function () {
|
expect(function () {
|
||||||
controller.setMode(controller.getMode());
|
controller.setMode(controller.getMode());
|
||||||
}).not.toThrow();
|
}).not.toThrow();
|
||||||
@ -133,6 +168,11 @@ define(
|
|||||||
expect(controller.stepBackPanZoom).not.toThrow();
|
expect(controller.stepBackPanZoom).not.toThrow();
|
||||||
expect(controller.unzoom).not.toThrow();
|
expect(controller.unzoom).not.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("indicates if a request is pending", function () {
|
||||||
|
// Placeholder; need to support requesting telemetry
|
||||||
|
expect(controller.isRequestPending()).toBeFalsy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
Reference in New Issue
Block a user