mirror of
https://github.com/nasa/openmct.git
synced 2025-06-15 21:58:13 +00:00
[Plot] Fill in specs
Fill in specs for elements used by the PlotController in order to improve coverage of the plot bundle. WTD-533.
This commit is contained in:
@ -9,6 +9,96 @@ define(
|
||||
"use strict";
|
||||
|
||||
describe("The plot palette", function () {
|
||||
it("can be used as a constructor", function () {
|
||||
// PlotPalette has all static methods, so make
|
||||
// sure it returns itself if used as a constructor.
|
||||
expect(new PlotPalette()).toBe(PlotPalette);
|
||||
});
|
||||
|
||||
it("has 30 unique colors in an integer format", function () {
|
||||
// Integer format may be useful internal to the application.
|
||||
// RGB 0-255
|
||||
var i, j;
|
||||
|
||||
// Used to verify one of R, G, B in loop below
|
||||
function verifyChannel(c) {
|
||||
expect(typeof c).toEqual("number");
|
||||
expect(c <= 255).toBeTruthy();
|
||||
expect(c >= 0).toBeTruthy();
|
||||
}
|
||||
|
||||
for (i = 0; i < 30; i += 1) {
|
||||
// Verify that we got an array of numbers
|
||||
expect(Array.isArray(PlotPalette.getIntegerColor(i)))
|
||||
.toBeTruthy();
|
||||
expect(PlotPalette.getIntegerColor(i).length).toEqual(3);
|
||||
|
||||
// Verify all three channels for type and range
|
||||
PlotPalette.getIntegerColor(i).forEach(verifyChannel);
|
||||
|
||||
// Verify uniqueness
|
||||
for (j = i + 1; j < 30; j += 1) {
|
||||
expect(PlotPalette.getIntegerColor(i)).not.toEqual(
|
||||
PlotPalette.getIntegerColor(j)
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
it("has 30 unique colors in a floating-point format", function () {
|
||||
// Float format is useful to WebGL.
|
||||
// RGB 0.0-1.1
|
||||
var i, j;
|
||||
|
||||
// Used to verify one of R, G, B in loop below
|
||||
function verifyChannel(c) {
|
||||
expect(typeof c).toEqual("number");
|
||||
expect(c <= 1.0).toBeTruthy();
|
||||
expect(c >= 0.0).toBeTruthy();
|
||||
}
|
||||
|
||||
for (i = 0; i < 30; i += 1) {
|
||||
// Verify that we got an array of numbers
|
||||
expect(Array.isArray(PlotPalette.getFloatColor(i)))
|
||||
.toBeTruthy();
|
||||
expect(PlotPalette.getFloatColor(i).length).toEqual(4);
|
||||
|
||||
// Verify all three channels for type and range
|
||||
PlotPalette.getFloatColor(i).forEach(verifyChannel);
|
||||
|
||||
// Verify uniqueness
|
||||
for (j = i + 1; j < 30; j += 1) {
|
||||
expect(PlotPalette.getFloatColor(i)).not.toEqual(
|
||||
PlotPalette.getFloatColor(j)
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
it("has 30 unique colors in a string format", function () {
|
||||
// String format is useful in stylesheets
|
||||
// #RRGGBB in hex
|
||||
var i, j, c;
|
||||
|
||||
|
||||
for (i = 0; i < 30; i += 1) {
|
||||
c = PlotPalette.getStringColor(i);
|
||||
|
||||
// Verify that we #-style color strings
|
||||
expect(typeof c).toEqual('string');
|
||||
expect(c.length).toEqual(7);
|
||||
expect(/^#[0-9a-fA-F]+$/.test(c)).toBeTruthy();
|
||||
|
||||
// Verify uniqueness
|
||||
for (j = i + 1; j < 30; j += 1) {
|
||||
expect(PlotPalette.getStringColor(i)).not.toEqual(
|
||||
PlotPalette.getStringColor(j)
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
Reference in New Issue
Block a user