From 112d94e1890301852e0fa69a471c33640289e374 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 12 Dec 2014 11:20:04 -0800 Subject: [PATCH] [Plot] Specs for PlotModeOptions Add specs for PlotModeOptions, introduced to allow switching between Stacked and Overlaid mode for WTD-625. --- .../plot/test/modes/PlotModeOptionsSpec.js | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/platform/features/plot/test/modes/PlotModeOptionsSpec.js b/platform/features/plot/test/modes/PlotModeOptionsSpec.js index 4c3cf74ae3..99c9f3b0b3 100644 --- a/platform/features/plot/test/modes/PlotModeOptionsSpec.js +++ b/platform/features/plot/test/modes/PlotModeOptionsSpec.js @@ -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); + }); }); } ); \ No newline at end of file