mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 07:08:12 +00:00
[Plot] Complete specs for plot updater
Complete specs for plot updater; particularly, address case (and fix bug in case) where maximum buffer size has been hit. WTD-751.
This commit is contained in:
@ -49,7 +49,8 @@ define(
|
||||
updater = new PlotUpdater(
|
||||
mockSubscription,
|
||||
testDomain,
|
||||
testRange
|
||||
testRange,
|
||||
1350 // Smaller max size for easier testing
|
||||
);
|
||||
});
|
||||
|
||||
@ -66,7 +67,7 @@ define(
|
||||
|
||||
it("maintains a buffer of received telemetry", function () {
|
||||
// Count should be large enough to trigger a buffer resize
|
||||
var count = 1000,
|
||||
var count = 750,
|
||||
i;
|
||||
|
||||
// Increment values exposed by subscription
|
||||
@ -107,6 +108,54 @@ define(
|
||||
}
|
||||
});
|
||||
|
||||
it("can handle delayed telemetry object availability", function () {
|
||||
// The case can occur where getTelemetryObjects() returns an
|
||||
// empty array - specifically, while objects are still being
|
||||
// loaded. The updater needs to be able to cope with that
|
||||
// case.
|
||||
var tmp = mockSubscription.getTelemetryObjects();
|
||||
mockSubscription.getTelemetryObjects.andReturn([]);
|
||||
|
||||
// Reinstantiate with the empty subscription
|
||||
updater = new PlotUpdater(
|
||||
mockSubscription,
|
||||
testDomain,
|
||||
testRange
|
||||
);
|
||||
|
||||
// Should have 0 buffers for 0 objects
|
||||
expect(updater.getBuffers().length).toEqual(0);
|
||||
|
||||
// Restore the three objects the test subscription would
|
||||
// normally have.
|
||||
mockSubscription.getTelemetryObjects.andReturn(tmp);
|
||||
updater.update();
|
||||
|
||||
// Should have 3 buffers for 3 objects
|
||||
expect(updater.getBuffers().length).toEqual(3);
|
||||
});
|
||||
|
||||
|
||||
it("shifts buffer upon expansion", function () {
|
||||
// Count should be large enough to hit buffer's max size
|
||||
var count = 1400,
|
||||
i;
|
||||
|
||||
// Initial update; should have 3 in first position
|
||||
// (a's initial domain value)
|
||||
updater.update();
|
||||
expect(updater.getBuffers()[0][1]).toEqual(123);
|
||||
|
||||
// Simulate a lot of telemetry updates
|
||||
for (i = 0; i < count; i += 1) {
|
||||
testDomainValues.a += 1;
|
||||
testRangeValues.a += 1;
|
||||
updater.update();
|
||||
}
|
||||
|
||||
// Value at front of the buffer should have been pushed out
|
||||
expect(updater.getBuffers()[0][1]).not.toEqual(123);
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
Reference in New Issue
Block a user