mirror of
https://github.com/nasa/openmct.git
synced 2025-06-14 05:08:15 +00:00
[Time Conductor] Update PlotAxis spec
...to reflect ability to change domain selection without reinstantiation, supporting integration of domain-driven formatting of X axis values in a plot.
This commit is contained in:
@ -92,7 +92,7 @@ define(
|
|||||||
if (!optionKeys[key] && !newOptions[key]) {
|
if (!optionKeys[key] && !newOptions[key]) {
|
||||||
toAdd.push(option);
|
toAdd.push(option);
|
||||||
}
|
}
|
||||||
newOptions[option.key] = true;
|
newOptions[key] = true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -30,7 +30,12 @@ define(
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
describe("A plot axis", function () {
|
describe("A plot axis", function () {
|
||||||
var testMetadatas = [
|
var testMetadatas,
|
||||||
|
testDefault,
|
||||||
|
axis;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
testMetadatas = [
|
||||||
{
|
{
|
||||||
tests: [
|
tests: [
|
||||||
{ key: "t0", name: "T0" },
|
{ key: "t0", name: "T0" },
|
||||||
@ -52,13 +57,14 @@ define(
|
|||||||
{ key: "t6", name: "T6" }
|
{ key: "t6", name: "T6" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
];
|
||||||
testDefault = { key: "test", name: "Test" },
|
testDefault = { key: "test", name: "Test" };
|
||||||
controller = new PlotAxis("tests", testMetadatas, testDefault);
|
axis = new PlotAxis("tests", testMetadatas, testDefault);
|
||||||
|
});
|
||||||
|
|
||||||
it("pulls out a list of domain or range options", function () {
|
it("pulls out a list of domain or range options", function () {
|
||||||
// Should have filtered out duplicates, etc
|
// Should have filtered out duplicates, etc
|
||||||
expect(controller.options).toEqual([
|
expect(axis.options).toEqual([
|
||||||
{ key: "t0", name: "T0" },
|
{ key: "t0", name: "T0" },
|
||||||
{ key: "t1", name: "T1" },
|
{ key: "t1", name: "T1" },
|
||||||
{ key: "t2", name: "T2" },
|
{ key: "t2", name: "T2" },
|
||||||
@ -70,7 +76,7 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("chooses the first option as a default", function () {
|
it("chooses the first option as a default", function () {
|
||||||
expect(controller.active).toEqual({ key: "t0", name: "T0" });
|
expect(axis.active).toEqual({ key: "t0", name: "T0" });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("falls back to a provided default if no options are present", function () {
|
it("falls back to a provided default if no options are present", function () {
|
||||||
@ -78,6 +84,26 @@ define(
|
|||||||
.toEqual(testDefault);
|
.toEqual(testDefault);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("allows options to be chosen by key", function () {
|
||||||
|
axis.chooseOption("t3");
|
||||||
|
expect(axis.active).toEqual({ key: "t3", name: "T3" });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("reflects changes to applicable metadata", function () {
|
||||||
|
axis.updateMetadata([ testMetadatas[1] ]);
|
||||||
|
expect(axis.options).toEqual([
|
||||||
|
{ key: "t0", name: "T0" },
|
||||||
|
{ key: "t2", name: "T2" }
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("returns the same array instance for unchanged metadata", function () {
|
||||||
|
// ...to avoid triggering extra digest cycles.
|
||||||
|
var oldInstance = axis.options;
|
||||||
|
axis.updateMetadata(testMetadatas);
|
||||||
|
expect(axis.options).toBe(oldInstance);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user