mirror of
https://github.com/nasa/openmct.git
synced 2025-01-31 16:36:13 +00:00
[Plot] Add specs for PlotPanZoomStackGroup
Add specs to verify the behavior of PlotPanZoomStackGroup, which is responsible for synchronizing the domain axis between multiple sub-plots in a stacked plot view. WTD-625.
This commit is contained in:
parent
a2d22a4558
commit
7ea63fce8c
@ -38,7 +38,7 @@ define(
|
|||||||
|
|
||||||
function clearPanZoom() {
|
function clearPanZoom() {
|
||||||
stacks.forEach(function (stack) {
|
stacks.forEach(function (stack) {
|
||||||
stack.popPanZoom();
|
stack.clearPanZoom();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,10 +5,103 @@
|
|||||||
*/
|
*/
|
||||||
define(
|
define(
|
||||||
["../../src/elements/PlotPanZoomStackGroup"],
|
["../../src/elements/PlotPanZoomStackGroup"],
|
||||||
function (PlotController) {
|
function (PlotPanZoomStackGroup) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var COUNT = 8;
|
||||||
|
|
||||||
describe("A plot pan-zoom stack group", function () {
|
describe("A plot pan-zoom stack group", function () {
|
||||||
|
var stacks,
|
||||||
|
group;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
group = new PlotPanZoomStackGroup(COUNT);
|
||||||
|
stacks = [];
|
||||||
|
while (stacks.length < COUNT) {
|
||||||
|
stacks.push(group.getPanZoomStack(stacks.length));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it("creates a number of separate stacks", function () {
|
||||||
|
expect(group.getPanZoomStack(0)).toBeDefined();
|
||||||
|
expect(group.getPanZoomStack(COUNT - 1)).toBeDefined();
|
||||||
|
expect(group.getPanZoomStack(COUNT)).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("synchronizes pan-zoom stack depth", function () {
|
||||||
|
expect(group.getDepth()).toEqual(1);
|
||||||
|
group.getPanZoomStack(1).pushPanZoom([ 10, 20 ], [ 30, 40 ]);
|
||||||
|
stacks.forEach(function (stack) {
|
||||||
|
expect(stack.getDepth()).toEqual(2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("synchronizes domain but not range", function () {
|
||||||
|
// Set up different initial states
|
||||||
|
stacks.forEach(function (stack, i) {
|
||||||
|
stack.pushPanZoom([ i, i ], [ i, i ]);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Push a new pan-zoom state onto one of the stacks
|
||||||
|
group.getPanZoomStack(1).pushPanZoom([ 99, 99 ], [ 42, 42 ]);
|
||||||
|
|
||||||
|
// Should changed domain values for all stacks, but
|
||||||
|
// only changed range values for stack 1
|
||||||
|
stacks.forEach(function (stack, i) {
|
||||||
|
expect(stack.getOrigin())
|
||||||
|
.toEqual([99, i === 1 ? 99 : i]);
|
||||||
|
expect(stack.getDimensions())
|
||||||
|
.toEqual([42, i === 1 ? 42 : i]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("synchronizes base pan-zoom", function () {
|
||||||
|
group.setBasePanZoom([10, 9], [8, 7]);
|
||||||
|
stacks.forEach(function (stack) {
|
||||||
|
expect(stack.getOrigin()).toEqual([10, 9]);
|
||||||
|
expect(stack.getDimensions()).toEqual([8, 7]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("clears pan-zoom on request", function () {
|
||||||
|
// Set up different initial states
|
||||||
|
stacks.forEach(function (stack, i) {
|
||||||
|
stack.pushPanZoom([ i, i ], [ i, i ]);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Verify that we have a greater depth
|
||||||
|
expect(group.getDepth() > 1).toBeTruthy();
|
||||||
|
|
||||||
|
// Clear the pan-zoom state
|
||||||
|
group.clearPanZoom();
|
||||||
|
|
||||||
|
// Should be back down to our initial state
|
||||||
|
expect(group.getDepth()).toEqual(1);
|
||||||
|
stacks.forEach(function (stack) {
|
||||||
|
expect(stack.getDepth()).toEqual(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("pops pan-zoom on request", function () {
|
||||||
|
// Set up different initial states
|
||||||
|
stacks.forEach(function (stack, i) {
|
||||||
|
stack.pushPanZoom([ i, i ], [ i, i ]);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Verify that we have a greater depth
|
||||||
|
expect(group.getDepth()).toEqual(COUNT + 1);
|
||||||
|
|
||||||
|
// Clear the pan-zoom state
|
||||||
|
group.popPanZoom();
|
||||||
|
|
||||||
|
// Should be back down to our initial state
|
||||||
|
expect(group.getDepth()).toEqual(COUNT);
|
||||||
|
stacks.forEach(function (stack) {
|
||||||
|
expect(stack.getDepth()).toEqual(COUNT);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
Loading…
x
Reference in New Issue
Block a user