[Telemetry] Update plot specs
Update plot specs to reflect refactoring out of formatter for telemetry values, WTD-599.
This commit is contained in:
@@ -10,8 +10,11 @@ define(
|
||||
|
||||
describe("Overlaid plot mode", function () {
|
||||
var mockDomainObject,
|
||||
mockSubPlotFactory,
|
||||
mockSubPlot,
|
||||
mockPrepared,
|
||||
testBuffers,
|
||||
testDrawingObjects,
|
||||
mode;
|
||||
|
||||
function mockElement(x, y, w, h) {
|
||||
@@ -22,10 +25,24 @@ define(
|
||||
};
|
||||
}
|
||||
|
||||
function doZoom(subplot, i) {
|
||||
subplot.startMarquee({ target: mockElement() });
|
||||
subplot.hover({ target: mockElement() });
|
||||
subplot.endMarquee({ target: mockElement() });
|
||||
function createMockSubPlot() {
|
||||
var mockSubPlot = jasmine.createSpyObj(
|
||||
"subPlot",
|
||||
[
|
||||
"setDomainOffset",
|
||||
"hover",
|
||||
"startMarquee",
|
||||
"endMarquee",
|
||||
"getDrawingObject",
|
||||
"update"
|
||||
]
|
||||
),
|
||||
testDrawingObject = {};
|
||||
|
||||
// Track drawing objects in order of creation
|
||||
testDrawingObjects.push(testDrawingObject);
|
||||
mockSubPlot.getDrawingObject.andReturn(testDrawingObject);
|
||||
return mockSubPlot;
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
@@ -33,12 +50,18 @@ define(
|
||||
"domainObject",
|
||||
[ "getId", "getModel", "getCapability" ]
|
||||
);
|
||||
mockSubPlotFactory = jasmine.createSpyObj(
|
||||
"subPlotFactory",
|
||||
[ "createSubPlot" ]
|
||||
);
|
||||
// Prepared telemetry data
|
||||
mockPrepared = jasmine.createSpyObj(
|
||||
"prepared",
|
||||
[ "getDomainOffset", "getOrigin", "getDimensions", "getBuffers" ]
|
||||
);
|
||||
|
||||
mockSubPlotFactory.createSubPlot.andCallFake(createMockSubPlot);
|
||||
|
||||
// Act as if we have three buffers full of data
|
||||
testBuffers = [["a"], ["b"], ["c"]];
|
||||
mockPrepared.getBuffers.andReturn(testBuffers);
|
||||
@@ -46,11 +69,14 @@ define(
|
||||
mockPrepared.getOrigin.andReturn([10, 10]);
|
||||
mockPrepared.getDimensions.andReturn([500, 500]);
|
||||
|
||||
// Clear out drawing objects
|
||||
testDrawingObjects = [];
|
||||
|
||||
mode = new PlotOverlayMode([
|
||||
mockDomainObject,
|
||||
mockDomainObject,
|
||||
mockDomainObject
|
||||
]);
|
||||
], mockSubPlotFactory);
|
||||
});
|
||||
|
||||
it("creates one sub-plot for all domain objects", function () {
|
||||
@@ -68,14 +94,15 @@ define(
|
||||
|
||||
mode.plotTelemetry(mockPrepared);
|
||||
|
||||
// Should all each have one line
|
||||
mode.getSubPlots().forEach(function (subplot, i) {
|
||||
// Should have one sub-plot with three lines
|
||||
testDrawingObjects.forEach(function (testDrawingObject, i) {
|
||||
// Either empty list or undefined is fine;
|
||||
// just want to make sure there are no lines.
|
||||
expect(subplot.getDrawingObject().lines.length)
|
||||
expect(testDrawingObject.lines.length)
|
||||
.toEqual(3);
|
||||
// Make sure all buffers were drawn, in order.
|
||||
subplot.getDrawingObject().lines.forEach(function (line, j) {
|
||||
// Make sure the right buffer was drawn to the
|
||||
// right subplot.
|
||||
testDrawingObject.lines.forEach(function (line, j) {
|
||||
expect(line.buffer).toEqual(testBuffers[j]);
|
||||
});
|
||||
});
|
||||
@@ -86,7 +113,10 @@ define(
|
||||
expect(mode.isZoomed()).toBeFalsy();
|
||||
|
||||
// Trigger some zoom changes
|
||||
mode.getSubPlots().forEach(doZoom);
|
||||
mockSubPlotFactory.createSubPlot.calls.forEach(function (c) {
|
||||
// Second argument to the factory was pan-zoom stack
|
||||
c.args[1].pushPanZoom([1, 2], [3, 4]);
|
||||
});
|
||||
|
||||
// Should start out unzoomed
|
||||
expect(mode.isZoomed()).toBeTruthy();
|
||||
@@ -94,8 +124,10 @@ define(
|
||||
|
||||
it("supports unzooming", function () {
|
||||
// Trigger some zoom changes
|
||||
mode.getSubPlots().forEach(doZoom);
|
||||
|
||||
mockSubPlotFactory.createSubPlot.calls.forEach(function (c) {
|
||||
// Second argument to the factory was pan-zoom stack
|
||||
c.args[1].pushPanZoom([1, 2], [3, 4]);
|
||||
});
|
||||
// Verify that we are indeed zoomed now
|
||||
expect(mode.isZoomed()).toBeTruthy();
|
||||
|
||||
@@ -108,12 +140,16 @@ define(
|
||||
|
||||
it("supports stepping back through zoom states", function () {
|
||||
// Trigger some zoom changes
|
||||
mode.getSubPlots().forEach(doZoom);
|
||||
mockSubPlotFactory.createSubPlot.calls.forEach(function (c) {
|
||||
// Second argument to the factory was pan-zoom stack
|
||||
c.args[1].pushPanZoom([1, 2], [3, 4]);
|
||||
});
|
||||
|
||||
// Step back the same number of zoom changes
|
||||
mode.getSubPlots().forEach(function (subplot, i) {
|
||||
mockSubPlotFactory.createSubPlot.calls.forEach(function (c) {
|
||||
// Should still be zoomed at start of each iteration
|
||||
expect(mode.isZoomed()).toBeTruthy();
|
||||
// Step back one of the zoom changes.
|
||||
mode.stepBackPanZoom();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user