mirror of
https://github.com/nasa/openmct.git
synced 2025-04-20 09:01:14 +00:00
[Plot] Add test cases
Add test cases to spec for PlotUpdater to reflect changes for merging streaming and historical data. WTD-806.
This commit is contained in:
parent
74b9d68dc8
commit
ffcd91f88d
@ -14,6 +14,7 @@ define(
|
||||
testRange,
|
||||
testDomainValues,
|
||||
testRangeValues,
|
||||
mockSeries,
|
||||
updater;
|
||||
|
||||
function makeMockDomainObject(id) {
|
||||
@ -33,6 +34,10 @@ define(
|
||||
"subscription",
|
||||
[ "getDomainValue", "getRangeValue", "getTelemetryObjects" ]
|
||||
);
|
||||
mockSeries = jasmine.createSpyObj(
|
||||
'series',
|
||||
['getPointCount', 'getDomainValue', 'getRangeValue']
|
||||
);
|
||||
testDomain = "testDomain";
|
||||
testRange = "testRange";
|
||||
testDomainValues = { a: 3, b: 7, c: 13 };
|
||||
@ -92,6 +97,76 @@ define(
|
||||
expect(updater.getLineBuffers().length).toEqual(3);
|
||||
});
|
||||
|
||||
it("accepts historical telemetry updates", function () {
|
||||
var mockObject = mockSubscription.getTelemetryObjects()[0];
|
||||
|
||||
mockSeries.getPointCount.andReturn(3);
|
||||
mockSeries.getDomainValue.andCallFake(function (i) {
|
||||
return 1000 + i * 1000;
|
||||
});
|
||||
mockSeries.getRangeValue.andReturn(10);
|
||||
|
||||
// PlotLine & PlotLineBuffer are tested for most of the
|
||||
// details here, so just check for some expected side
|
||||
// effect; in this case, should see more points in the buffer
|
||||
expect(updater.getLineBuffers()[0].getLength()).toEqual(1);
|
||||
updater.addHistorical(mockObject, mockSeries);
|
||||
expect(updater.getLineBuffers()[0].getLength()).toEqual(4);
|
||||
});
|
||||
|
||||
it("clears the domain offset if no objects are present", function () {
|
||||
mockSubscription.getTelemetryObjects.andReturn([]);
|
||||
updater.update();
|
||||
expect(updater.getDomainOffset()).toBeUndefined();
|
||||
});
|
||||
|
||||
it("handles empty historical telemetry updates", function () {
|
||||
// General robustness check for when a series is empty
|
||||
var mockObject = mockSubscription.getTelemetryObjects()[0];
|
||||
|
||||
mockSeries.getPointCount.andReturn(0);
|
||||
mockSeries.getDomainValue.andCallFake(function (i) {
|
||||
return 1000 + i * 1000;
|
||||
});
|
||||
mockSeries.getRangeValue.andReturn(10);
|
||||
|
||||
// PlotLine & PlotLineBuffer are tested for most of the
|
||||
// details here, so just check for some expected side
|
||||
// effect; in this case, should see more points in the buffer
|
||||
expect(updater.getLineBuffers()[0].getLength()).toEqual(1);
|
||||
updater.addHistorical(mockObject, mockSeries);
|
||||
expect(updater.getLineBuffers()[0].getLength()).toEqual(1);
|
||||
});
|
||||
|
||||
it("can initialize domain offset from historical telemetry", function () {
|
||||
var tmp = mockSubscription.getTelemetryObjects();
|
||||
|
||||
mockSubscription.getTelemetryObjects.andReturn([]);
|
||||
|
||||
// Reinstantiate with the empty subscription
|
||||
updater = new PlotUpdater(
|
||||
mockSubscription,
|
||||
testDomain,
|
||||
testRange
|
||||
);
|
||||
|
||||
// Restore subscription, provide some historical data
|
||||
mockSubscription.getTelemetryObjects.andReturn(tmp);
|
||||
mockSeries.getPointCount.andReturn(3);
|
||||
mockSeries.getDomainValue.andCallFake(function (i) {
|
||||
return 1000 + i * 1000;
|
||||
});
|
||||
mockSeries.getRangeValue.andReturn(10);
|
||||
|
||||
// PlotLine & PlotLineBuffer are tested for most of the
|
||||
// details here, so just check for some expected side
|
||||
// effect; in this case, should see more points in the buffer
|
||||
expect(updater.getDomainOffset()).toBeUndefined();
|
||||
updater.addHistorical(tmp[0], mockSeries);
|
||||
expect(updater.getDomainOffset()).toBeDefined();
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
);
|
Loading…
x
Reference in New Issue
Block a user