mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 23:28: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:
@ -14,6 +14,7 @@ define(
|
|||||||
testRange,
|
testRange,
|
||||||
testDomainValues,
|
testDomainValues,
|
||||||
testRangeValues,
|
testRangeValues,
|
||||||
|
mockSeries,
|
||||||
updater;
|
updater;
|
||||||
|
|
||||||
function makeMockDomainObject(id) {
|
function makeMockDomainObject(id) {
|
||||||
@ -33,6 +34,10 @@ define(
|
|||||||
"subscription",
|
"subscription",
|
||||||
[ "getDomainValue", "getRangeValue", "getTelemetryObjects" ]
|
[ "getDomainValue", "getRangeValue", "getTelemetryObjects" ]
|
||||||
);
|
);
|
||||||
|
mockSeries = jasmine.createSpyObj(
|
||||||
|
'series',
|
||||||
|
['getPointCount', 'getDomainValue', 'getRangeValue']
|
||||||
|
);
|
||||||
testDomain = "testDomain";
|
testDomain = "testDomain";
|
||||||
testRange = "testRange";
|
testRange = "testRange";
|
||||||
testDomainValues = { a: 3, b: 7, c: 13 };
|
testDomainValues = { a: 3, b: 7, c: 13 };
|
||||||
@ -92,6 +97,76 @@ define(
|
|||||||
expect(updater.getLineBuffers().length).toEqual(3);
|
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();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
Reference in New Issue
Block a user