mirror of
https://github.com/nasa/openmct.git
synced 2024-12-21 14:07:50 +00:00
Fixed failing tests
This commit is contained in:
parent
7cc008ed01
commit
099c56c407
@ -197,7 +197,6 @@ define(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when form values are changed. Synchronizes the form with
|
* Called when form values are changed. Synchronizes the form with
|
||||||
* the time conductor
|
* the time conductor
|
||||||
@ -318,7 +317,6 @@ define(
|
|||||||
var zoomDefaults = this.conductor.timeSystem().defaults().zoom;
|
var zoomDefaults = this.conductor.timeSystem().defaults().zoom;
|
||||||
var timeSpan = Math.pow((1 - sliderValue), 4) * (zoomDefaults.min - zoomDefaults.max);
|
var timeSpan = Math.pow((1 - sliderValue), 4) * (zoomDefaults.min - zoomDefaults.max);
|
||||||
|
|
||||||
|
|
||||||
var zoom = this.conductorViewService.zoom(timeSpan);
|
var zoom = this.conductorViewService.zoom(timeSpan);
|
||||||
|
|
||||||
this.$scope.boundsModel.start = zoom.bounds.start;
|
this.$scope.boundsModel.start = zoom.bounds.start;
|
||||||
|
@ -28,6 +28,8 @@ define(['./TimeConductorController'], function (TimeConductorController) {
|
|||||||
var mockConductorViewService;
|
var mockConductorViewService;
|
||||||
var mockTimeSystems;
|
var mockTimeSystems;
|
||||||
var controller;
|
var controller;
|
||||||
|
var mockFormatService;
|
||||||
|
var mockFormat;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockScope = jasmine.createSpyObj("$scope", [
|
mockScope = jasmine.createSpyObj("$scope", [
|
||||||
@ -52,34 +54,32 @@ define(['./TimeConductorController'], function (TimeConductorController) {
|
|||||||
"availableModes",
|
"availableModes",
|
||||||
"mode",
|
"mode",
|
||||||
"availableTimeSystems",
|
"availableTimeSystems",
|
||||||
"deltas"
|
"deltas",
|
||||||
|
"deltas",
|
||||||
|
"on",
|
||||||
|
"off"
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
mockConductorViewService.availableModes.andReturn([]);
|
mockConductorViewService.availableModes.andReturn([]);
|
||||||
mockConductorViewService.availableTimeSystems.andReturn([]);
|
mockConductorViewService.availableTimeSystems.andReturn([]);
|
||||||
|
|
||||||
|
mockFormatService = jasmine.createSpyObj('formatService',[
|
||||||
|
'getFormat'
|
||||||
|
]);
|
||||||
|
mockFormat = jasmine.createSpyObj('format', [
|
||||||
|
'format'
|
||||||
|
]);
|
||||||
|
mockFormatService.getFormat.andReturn(mockFormat);
|
||||||
|
|
||||||
mockTimeSystems = [];
|
mockTimeSystems = [];
|
||||||
});
|
});
|
||||||
|
|
||||||
function getListener(name) {
|
function getListener(target, event) {
|
||||||
return mockTimeConductor.on.calls.filter(function (call) {
|
return target.calls.filter(function (call) {
|
||||||
return call.args[0] === name;
|
return call.args[0] === event;
|
||||||
})[0].args[1];
|
})[0].args[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("", function () {
|
|
||||||
beforeEach(function () {
|
|
||||||
controller = new TimeConductorController(
|
|
||||||
mockScope,
|
|
||||||
mockWindow,
|
|
||||||
mockTimeConductor,
|
|
||||||
mockConductorViewService,
|
|
||||||
mockTimeSystems
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("when time conductor state changes", function () {
|
describe("when time conductor state changes", function () {
|
||||||
var mockFormat;
|
var mockFormat;
|
||||||
var mockDeltaFormat;
|
var mockDeltaFormat;
|
||||||
@ -119,17 +119,18 @@ define(['./TimeConductorController'], function (TimeConductorController) {
|
|||||||
controller = new TimeConductorController(
|
controller = new TimeConductorController(
|
||||||
mockScope,
|
mockScope,
|
||||||
mockWindow,
|
mockWindow,
|
||||||
mockTimeConductor,
|
{conductor: mockTimeConductor},
|
||||||
mockConductorViewService,
|
mockConductorViewService,
|
||||||
mockTimeSystems
|
mockTimeSystems,
|
||||||
|
mockFormatService
|
||||||
);
|
);
|
||||||
|
|
||||||
tsListener = getListener("timeSystem");
|
tsListener = getListener(mockTimeConductor.on, "timeSystem");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("listens for changes to conductor state", function () {
|
it("listens for changes to conductor state", function () {
|
||||||
expect(mockTimeConductor.on).toHaveBeenCalledWith("timeSystem", controller.changeTimeSystem);
|
expect(mockTimeConductor.on).toHaveBeenCalledWith("timeSystem", controller.changeTimeSystem);
|
||||||
expect(mockTimeConductor.on).toHaveBeenCalledWith("bounds", controller.setFormFromBounds);
|
expect(mockTimeConductor.on).toHaveBeenCalledWith("bounds", controller.changeBounds);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("deregisters conductor listens when scope is destroyed", function () {
|
it("deregisters conductor listens when scope is destroyed", function () {
|
||||||
@ -137,7 +138,7 @@ define(['./TimeConductorController'], function (TimeConductorController) {
|
|||||||
|
|
||||||
controller.destroy();
|
controller.destroy();
|
||||||
expect(mockTimeConductor.off).toHaveBeenCalledWith("timeSystem", controller.changeTimeSystem);
|
expect(mockTimeConductor.off).toHaveBeenCalledWith("timeSystem", controller.changeTimeSystem);
|
||||||
expect(mockTimeConductor.off).toHaveBeenCalledWith("bounds", controller.setFormFromBounds);
|
expect(mockTimeConductor.off).toHaveBeenCalledWith("bounds", controller.changeBounds);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when time system changes, sets time system on scope", function () {
|
it("when time system changes, sets time system on scope", function () {
|
||||||
@ -151,7 +152,11 @@ define(['./TimeConductorController'], function (TimeConductorController) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("when time system changes, sets defaults on scope", function () {
|
it("when time system changes, sets defaults on scope", function () {
|
||||||
expect(tsListener).toBeDefined();
|
mockDefaults.zoom = {
|
||||||
|
min: 100,
|
||||||
|
max: 10
|
||||||
|
};
|
||||||
|
mockTimeConductor.timeSystem.andReturn(timeSystem);
|
||||||
tsListener(timeSystem);
|
tsListener(timeSystem);
|
||||||
|
|
||||||
expect(mockScope.boundsModel.start).toEqual(defaultBounds.start);
|
expect(mockScope.boundsModel.start).toEqual(defaultBounds.start);
|
||||||
@ -159,6 +164,32 @@ define(['./TimeConductorController'], function (TimeConductorController) {
|
|||||||
|
|
||||||
expect(mockScope.boundsModel.startDelta).toEqual(defaultDeltas.start);
|
expect(mockScope.boundsModel.startDelta).toEqual(defaultDeltas.start);
|
||||||
expect(mockScope.boundsModel.endDelta).toEqual(defaultDeltas.end);
|
expect(mockScope.boundsModel.endDelta).toEqual(defaultDeltas.end);
|
||||||
|
|
||||||
|
expect(mockScope.timeSystemModel.minZoom).toBe(mockDefaults.zoom.min);
|
||||||
|
expect(mockScope.timeSystemModel.maxZoom).toBe(mockDefaults.zoom.max);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("when bounds change, sets the correct zoom slider value", function() {
|
||||||
|
var bounds = {
|
||||||
|
start: 0,
|
||||||
|
end: 50
|
||||||
|
};
|
||||||
|
mockDefaults.zoom = {
|
||||||
|
min: 100,
|
||||||
|
max: 0
|
||||||
|
};
|
||||||
|
|
||||||
|
function exponentializer (rawValue){
|
||||||
|
return 1 - Math.pow(rawValue, 1 / 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
mockTimeConductor.timeSystem.andReturn(timeSystem);
|
||||||
|
//Set zoom defaults
|
||||||
|
tsListener(timeSystem);
|
||||||
|
|
||||||
|
controller.changeBounds(bounds);
|
||||||
|
expect(controller.currentZoom).toEqual(exponentializer(0.5));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when bounds change, sets them on scope", function () {
|
it("when bounds change, sets them on scope", function () {
|
||||||
@ -167,7 +198,7 @@ define(['./TimeConductorController'], function (TimeConductorController) {
|
|||||||
end: 2
|
end: 2
|
||||||
};
|
};
|
||||||
|
|
||||||
var boundsListener = getListener("bounds");
|
var boundsListener = getListener(mockTimeConductor.on, "bounds");
|
||||||
expect(boundsListener).toBeDefined();
|
expect(boundsListener).toBeDefined();
|
||||||
boundsListener(bounds);
|
boundsListener(bounds);
|
||||||
|
|
||||||
@ -225,9 +256,10 @@ define(['./TimeConductorController'], function (TimeConductorController) {
|
|||||||
controller = new TimeConductorController(
|
controller = new TimeConductorController(
|
||||||
mockScope,
|
mockScope,
|
||||||
mockWindow,
|
mockWindow,
|
||||||
mockTimeConductor,
|
{conductor: mockTimeConductor},
|
||||||
mockConductorViewService,
|
mockConductorViewService,
|
||||||
mockTimeSystemConstructors
|
mockTimeSystemConstructors,
|
||||||
|
mockFormatService
|
||||||
);
|
);
|
||||||
|
|
||||||
mockConductorViewService.availableTimeSystems.andReturn(mockTimeSystems);
|
mockConductorViewService.availableTimeSystems.andReturn(mockTimeSystems);
|
||||||
@ -240,9 +272,10 @@ define(['./TimeConductorController'], function (TimeConductorController) {
|
|||||||
controller = new TimeConductorController(
|
controller = new TimeConductorController(
|
||||||
mockScope,
|
mockScope,
|
||||||
mockWindow,
|
mockWindow,
|
||||||
mockTimeConductor,
|
{conductor: mockTimeConductor},
|
||||||
mockConductorViewService,
|
mockConductorViewService,
|
||||||
mockTimeSystemConstructors
|
mockTimeSystemConstructors,
|
||||||
|
mockFormatService
|
||||||
);
|
);
|
||||||
|
|
||||||
mockConductorViewService.availableTimeSystems.andReturn(mockTimeSystems);
|
mockConductorViewService.availableTimeSystems.andReturn(mockTimeSystems);
|
||||||
@ -264,9 +297,10 @@ define(['./TimeConductorController'], function (TimeConductorController) {
|
|||||||
controller = new TimeConductorController(
|
controller = new TimeConductorController(
|
||||||
mockScope,
|
mockScope,
|
||||||
mockWindow,
|
mockWindow,
|
||||||
mockTimeConductor,
|
{conductor: mockTimeConductor},
|
||||||
mockConductorViewService,
|
mockConductorViewService,
|
||||||
mockTimeSystemConstructors
|
mockTimeSystemConstructors,
|
||||||
|
mockFormatService
|
||||||
);
|
);
|
||||||
|
|
||||||
controller.updateBoundsFromForm(formModel);
|
controller.updateBoundsFromForm(formModel);
|
||||||
@ -286,9 +320,10 @@ define(['./TimeConductorController'], function (TimeConductorController) {
|
|||||||
controller = new TimeConductorController(
|
controller = new TimeConductorController(
|
||||||
mockScope,
|
mockScope,
|
||||||
mockWindow,
|
mockWindow,
|
||||||
mockTimeConductor,
|
{conductor: mockTimeConductor},
|
||||||
mockConductorViewService,
|
mockConductorViewService,
|
||||||
mockTimeSystemConstructors
|
mockTimeSystemConstructors,
|
||||||
|
mockFormatService
|
||||||
);
|
);
|
||||||
|
|
||||||
controller.updateDeltasFromForm(formModel);
|
controller.updateDeltasFromForm(formModel);
|
||||||
@ -321,14 +356,35 @@ define(['./TimeConductorController'], function (TimeConductorController) {
|
|||||||
controller = new TimeConductorController(
|
controller = new TimeConductorController(
|
||||||
mockScope,
|
mockScope,
|
||||||
mockWindow,
|
mockWindow,
|
||||||
mockTimeConductor,
|
{conductor: mockTimeConductor},
|
||||||
mockConductorViewService,
|
mockConductorViewService,
|
||||||
mockTimeSystems
|
mockTimeSystems,
|
||||||
|
mockFormatService
|
||||||
);
|
);
|
||||||
|
|
||||||
controller.selectTimeSystemByKey('testTimeSystem');
|
controller.selectTimeSystemByKey('testTimeSystem');
|
||||||
expect(mockTimeConductor.timeSystem).toHaveBeenCalledWith(timeSystem, defaultBounds);
|
expect(mockTimeConductor.timeSystem).toHaveBeenCalledWith(timeSystem, defaultBounds);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("updates form bounds during pan events", function() {
|
||||||
|
var testBounds = {
|
||||||
|
start: 10,
|
||||||
|
end: 20
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(controller.$scope.boundsModel.start).not.toBe(testBounds.start);
|
||||||
|
expect(controller.$scope.boundsModel.end).not.toBe(testBounds.end);
|
||||||
|
|
||||||
|
// use registered CB instead
|
||||||
|
// controller.onPan(testBounds);
|
||||||
|
expect(controller.conductorViewService.on).toHaveBeenCalledWith("pan",
|
||||||
|
controller.onPan);
|
||||||
|
|
||||||
|
getListener(controller.conductorViewService.on, "pan")(testBounds);
|
||||||
|
|
||||||
|
expect(controller.$scope.boundsModel.start).toBe(testBounds.start);
|
||||||
|
expect(controller.$scope.boundsModel.end).toBe(testBounds.end);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -87,7 +87,7 @@ define(['./TimeConductorViewService'], function (TimeConductorViewService) {
|
|||||||
|
|
||||||
it("At a minimum supports fixed mode", function () {
|
it("At a minimum supports fixed mode", function () {
|
||||||
var mockTimeSystems = [mockConstructor(basicTimeSystem)];
|
var mockTimeSystems = [mockConstructor(basicTimeSystem)];
|
||||||
viewService = new TimeConductorViewService(mockTimeConductor, mockTimeSystems);
|
viewService = new TimeConductorViewService({conductor: mockTimeConductor}, mockTimeSystems);
|
||||||
|
|
||||||
var availableModes = viewService.availableModes();
|
var availableModes = viewService.availableModes();
|
||||||
expect(availableModes.fixed).toBeDefined();
|
expect(availableModes.fixed).toBeDefined();
|
||||||
@ -102,7 +102,7 @@ define(['./TimeConductorViewService'], function (TimeConductorViewService) {
|
|||||||
};
|
};
|
||||||
tickingTimeSystem.tickSources.andReturn([mockRealtimeTickSource]);
|
tickingTimeSystem.tickSources.andReturn([mockRealtimeTickSource]);
|
||||||
|
|
||||||
viewService = new TimeConductorViewService(mockTimeConductor, mockTimeSystems);
|
viewService = new TimeConductorViewService({conductor: mockTimeConductor}, mockTimeSystems);
|
||||||
|
|
||||||
var availableModes = viewService.availableModes();
|
var availableModes = viewService.availableModes();
|
||||||
expect(availableModes.realtime).toBeDefined();
|
expect(availableModes.realtime).toBeDefined();
|
||||||
@ -117,7 +117,7 @@ define(['./TimeConductorViewService'], function (TimeConductorViewService) {
|
|||||||
};
|
};
|
||||||
tickingTimeSystem.tickSources.andReturn([mockLADTickSource]);
|
tickingTimeSystem.tickSources.andReturn([mockLADTickSource]);
|
||||||
|
|
||||||
viewService = new TimeConductorViewService(mockTimeConductor, mockTimeSystems);
|
viewService = new TimeConductorViewService({conductor: mockTimeConductor}, mockTimeSystems);
|
||||||
|
|
||||||
var availableModes = viewService.availableModes();
|
var availableModes = viewService.availableModes();
|
||||||
expect(availableModes.lad).toBeDefined();
|
expect(availableModes.lad).toBeDefined();
|
||||||
@ -132,7 +132,7 @@ define(['./TimeConductorViewService'], function (TimeConductorViewService) {
|
|||||||
"destroy"
|
"destroy"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
viewService = new TimeConductorViewService(mockTimeConductor, mockTimeSystems);
|
viewService = new TimeConductorViewService({conductor: mockTimeConductor}, mockTimeSystems);
|
||||||
viewService.currentMode = oldMode;
|
viewService.currentMode = oldMode;
|
||||||
viewService.mode('fixed');
|
viewService.mode('fixed');
|
||||||
expect(oldMode.destroy).toHaveBeenCalled();
|
expect(oldMode.destroy).toHaveBeenCalled();
|
||||||
@ -149,7 +149,7 @@ define(['./TimeConductorViewService'], function (TimeConductorViewService) {
|
|||||||
};
|
};
|
||||||
tickingTimeSystem.tickSources.andReturn([mockRealtimeTickSource]);
|
tickingTimeSystem.tickSources.andReturn([mockRealtimeTickSource]);
|
||||||
|
|
||||||
viewService = new TimeConductorViewService(mockTimeConductor, mockTimeSystems);
|
viewService = new TimeConductorViewService({conductor: mockTimeConductor}, mockTimeSystems);
|
||||||
|
|
||||||
//Set time system to one known to support realtime mode
|
//Set time system to one known to support realtime mode
|
||||||
mockTimeConductor.timeSystem.andReturn(tickingTimeSystem);
|
mockTimeConductor.timeSystem.andReturn(tickingTimeSystem);
|
||||||
@ -169,7 +169,7 @@ define(['./TimeConductorViewService'], function (TimeConductorViewService) {
|
|||||||
};
|
};
|
||||||
tickingTimeSystem.tickSources.andReturn([mockRealtimeTickSource]);
|
tickingTimeSystem.tickSources.andReturn([mockRealtimeTickSource]);
|
||||||
|
|
||||||
viewService = new TimeConductorViewService(mockTimeConductor, mockTimeSystems);
|
viewService = new TimeConductorViewService({conductor: mockTimeConductor}, mockTimeSystems);
|
||||||
|
|
||||||
//Set time system to one known to not support realtime mode
|
//Set time system to one known to not support realtime mode
|
||||||
mockTimeConductor.timeSystem.andReturn(basicTimeSystem);
|
mockTimeConductor.timeSystem.andReturn(basicTimeSystem);
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
define(['./TimeOfInterestController'], function (TimeOfInterestController) {
|
define(['./TimeOfInterestController'], function (TimeOfInterestController) {
|
||||||
|
|
||||||
ddescribe("The time of interest controller", function () {
|
describe("The time of interest controller", function () {
|
||||||
var controller;
|
var controller;
|
||||||
var mockScope;
|
var mockScope;
|
||||||
var mockConductor;
|
var mockConductor;
|
||||||
|
@ -40,7 +40,8 @@ define(
|
|||||||
mockDomainObject,
|
mockDomainObject,
|
||||||
mockSeries,
|
mockSeries,
|
||||||
mockStatusCapability,
|
mockStatusCapability,
|
||||||
controller;
|
controller,
|
||||||
|
mockConductor;
|
||||||
|
|
||||||
function bind(method, thisObj) {
|
function bind(method, thisObj) {
|
||||||
return function () {
|
return function () {
|
||||||
@ -120,13 +121,23 @@ define(
|
|||||||
mockHandle.getRangeValue.andReturn(42);
|
mockHandle.getRangeValue.andReturn(42);
|
||||||
mockScope.domainObject = mockDomainObject;
|
mockScope.domainObject = mockDomainObject;
|
||||||
|
|
||||||
|
mockConductor = jasmine.createSpyObj('conductor', [
|
||||||
|
'on',
|
||||||
|
'off',
|
||||||
|
'bounds',
|
||||||
|
'timeSystem',
|
||||||
|
'timeOfInterest'
|
||||||
|
]);
|
||||||
|
|
||||||
controller = new PlotController(
|
controller = new PlotController(
|
||||||
mockScope,
|
mockScope,
|
||||||
mockElement,
|
mockElement,
|
||||||
mockExportImageService,
|
mockExportImageService,
|
||||||
mockFormatter,
|
mockFormatter,
|
||||||
mockHandler,
|
mockHandler,
|
||||||
mockThrottle
|
mockThrottle,
|
||||||
|
undefined,
|
||||||
|
{conductor: mockConductor}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ define(
|
|||||||
mockConfiguration,
|
mockConfiguration,
|
||||||
watches,
|
watches,
|
||||||
mockTableRow,
|
mockTableRow,
|
||||||
|
mockConductor,
|
||||||
controller;
|
controller;
|
||||||
|
|
||||||
function promise(value) {
|
function promise(value) {
|
||||||
@ -106,7 +107,8 @@ define(
|
|||||||
'getDatum',
|
'getDatum',
|
||||||
'promiseTelemetryObjects',
|
'promiseTelemetryObjects',
|
||||||
'getTelemetryObjects',
|
'getTelemetryObjects',
|
||||||
'request'
|
'request',
|
||||||
|
'getMetadata'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Arbitrary array with non-zero length, contents are not
|
// Arbitrary array with non-zero length, contents are not
|
||||||
@ -115,13 +117,22 @@ define(
|
|||||||
mockTelemetryHandle.promiseTelemetryObjects.andReturn(promise(undefined));
|
mockTelemetryHandle.promiseTelemetryObjects.andReturn(promise(undefined));
|
||||||
mockTelemetryHandle.getDatum.andReturn({});
|
mockTelemetryHandle.getDatum.andReturn({});
|
||||||
mockTelemetryHandle.request.andReturn(promise(undefined));
|
mockTelemetryHandle.request.andReturn(promise(undefined));
|
||||||
|
mockTelemetryHandle.getMetadata.andReturn([]);
|
||||||
|
|
||||||
mockTelemetryHandler = jasmine.createSpyObj('telemetryHandler', [
|
mockTelemetryHandler = jasmine.createSpyObj('telemetryHandler', [
|
||||||
'handle'
|
'handle'
|
||||||
]);
|
]);
|
||||||
mockTelemetryHandler.handle.andReturn(mockTelemetryHandle);
|
mockTelemetryHandler.handle.andReturn(mockTelemetryHandle);
|
||||||
|
|
||||||
controller = new TableController(mockScope, mockTelemetryHandler, mockTelemetryFormatter);
|
mockConductor = jasmine.createSpyObj('conductor', [
|
||||||
|
'on',
|
||||||
|
'off',
|
||||||
|
'bounds',
|
||||||
|
'timeSystem',
|
||||||
|
'timeOfInterest'
|
||||||
|
]);
|
||||||
|
|
||||||
|
controller = new TableController(mockScope, mockTelemetryHandler, mockTelemetryFormatter, {conductor: mockConductor});
|
||||||
controller.table = mockTable;
|
controller.table = mockTable;
|
||||||
controller.handle = mockTelemetryHandle;
|
controller.handle = mockTelemetryHandle;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user