[Plot] Specs for PlotModeOptions

Add specs for PlotModeOptions, introduced to
allow switching between Stacked and Overlaid
mode for WTD-625.
This commit is contained in:
Victor Woeltjen 2014-12-12 11:20:04 -08:00
parent 7ea63fce8c
commit 112d94e189

View File

@ -9,6 +9,55 @@ define(
"use strict";
describe("Plot mode options", function () {
var mockDomainObject;
beforeEach(function () {
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getModel", "getCapability" ]
);
});
it("offers only one option when one object is present", function () {
expect(
new PlotModeOptions([mockDomainObject])
.getModeOptions().length
).toEqual(1);
});
it("offers two options when multiple objects are present", function () {
var objects = [
mockDomainObject,
mockDomainObject,
mockDomainObject,
mockDomainObject
];
expect(
new PlotModeOptions(objects)
.getModeOptions().length
).toEqual(2);
});
it("allows modes to be changed", function () {
var plotModeOptions = new PlotModeOptions([
mockDomainObject,
mockDomainObject,
mockDomainObject,
mockDomainObject
]),
initialHandler = plotModeOptions.getModeHandler();
// Change the mode
plotModeOptions.getModeOptions().forEach(function (option) {
if (option !== plotModeOptions.getMode()) {
plotModeOptions.setMode(option);
}
});
// Mode should be different now
expect(plotModeOptions.getModeHandler())
.not.toBe(initialHandler);
});
});
}
);