2015-05-13 23:42:35 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
|
|
|
* as represented by the Administrator of the National Aeronautics and Space
|
|
|
|
* Administration. All rights reserved.
|
|
|
|
*
|
|
|
|
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*
|
|
|
|
* Open MCT Web includes source code licensed under additional open source
|
|
|
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
|
|
|
* this source code distribution or the Licensing information page available
|
|
|
|
* at runtime from the About dialog for additional information.
|
|
|
|
*****************************************************************************/
|
2015-02-19 17:13:45 +00:00
|
|
|
/*global define,describe,it,expect,beforeEach,jasmine,xit*/
|
2015-02-17 17:03:23 +00:00
|
|
|
|
|
|
|
define(
|
|
|
|
["../src/FixedController"],
|
|
|
|
function (FixedController) {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
describe("The Fixed Position controller", function () {
|
|
|
|
var mockScope,
|
2015-02-20 23:53:41 +00:00
|
|
|
mockQ,
|
|
|
|
mockDialogService,
|
2015-09-09 23:52:46 +00:00
|
|
|
mockHandler,
|
2015-02-17 17:03:23 +00:00
|
|
|
mockFormatter,
|
|
|
|
mockDomainObject,
|
2015-09-09 23:52:46 +00:00
|
|
|
mockHandle,
|
2015-06-25 18:35:18 +00:00
|
|
|
mockEvent,
|
2015-02-17 17:03:23 +00:00
|
|
|
testGrid,
|
|
|
|
testModel,
|
|
|
|
testValues,
|
2015-02-20 00:24:45 +00:00
|
|
|
testConfiguration,
|
2015-02-17 17:03:23 +00:00
|
|
|
controller;
|
|
|
|
|
|
|
|
// Utility function; find a watch for a given expression
|
|
|
|
function findWatch(expr) {
|
|
|
|
var watch;
|
|
|
|
mockScope.$watch.calls.forEach(function (call) {
|
|
|
|
if (call.args[0] === expr) {
|
|
|
|
watch = call.args[1];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return watch;
|
|
|
|
}
|
|
|
|
|
2015-02-17 18:50:02 +00:00
|
|
|
// As above, but for $on calls
|
|
|
|
function findOn(expr) {
|
|
|
|
var on;
|
|
|
|
mockScope.$on.calls.forEach(function (call) {
|
|
|
|
if (call.args[0] === expr) {
|
|
|
|
on = call.args[1];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return on;
|
|
|
|
}
|
|
|
|
|
2015-02-17 17:03:23 +00:00
|
|
|
function makeMockDomainObject(id) {
|
|
|
|
var mockObject = jasmine.createSpyObj(
|
|
|
|
'domainObject-' + id,
|
2015-06-23 20:43:00 +00:00
|
|
|
[ 'getId', 'getModel', 'getCapability' ]
|
2015-02-17 17:03:23 +00:00
|
|
|
);
|
|
|
|
mockObject.getId.andReturn(id);
|
2015-02-20 00:24:45 +00:00
|
|
|
mockObject.getModel.andReturn({ name: "Point " + id});
|
2015-02-17 17:03:23 +00:00
|
|
|
return mockObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
mockScope = jasmine.createSpyObj(
|
|
|
|
'$scope',
|
2015-02-17 18:50:02 +00:00
|
|
|
[ "$on", "$watch", "commit" ]
|
2015-02-17 17:03:23 +00:00
|
|
|
);
|
2015-09-09 23:52:46 +00:00
|
|
|
mockHandler = jasmine.createSpyObj(
|
|
|
|
'telemetryHandler',
|
|
|
|
[ 'handle' ]
|
2015-02-17 17:03:23 +00:00
|
|
|
);
|
2015-02-20 23:53:41 +00:00
|
|
|
mockQ = jasmine.createSpyObj('$q', ['when']);
|
|
|
|
mockDialogService = jasmine.createSpyObj(
|
|
|
|
'dialogService',
|
|
|
|
['getUserInput']
|
|
|
|
);
|
2015-02-17 17:03:23 +00:00
|
|
|
mockFormatter = jasmine.createSpyObj(
|
|
|
|
'telemetryFormatter',
|
|
|
|
[ 'formatDomainValue', 'formatRangeValue' ]
|
|
|
|
);
|
|
|
|
mockDomainObject = jasmine.createSpyObj(
|
|
|
|
'domainObject',
|
|
|
|
[ 'getId', 'getModel', 'getCapability' ]
|
|
|
|
);
|
2015-09-09 23:52:46 +00:00
|
|
|
mockHandle = jasmine.createSpyObj(
|
2015-02-17 17:03:23 +00:00
|
|
|
'subscription',
|
2015-09-09 23:52:46 +00:00
|
|
|
[
|
|
|
|
'unsubscribe',
|
|
|
|
'getDomainValue',
|
|
|
|
'getTelemetryObjects',
|
|
|
|
'getRangeValue',
|
2015-09-16 22:23:08 +00:00
|
|
|
'getDatum',
|
|
|
|
'request'
|
2015-09-09 23:52:46 +00:00
|
|
|
]
|
2015-02-17 17:03:23 +00:00
|
|
|
);
|
2015-06-25 18:35:18 +00:00
|
|
|
mockEvent = jasmine.createSpyObj(
|
|
|
|
'event',
|
2015-06-26 18:53:45 +00:00
|
|
|
[ 'preventDefault' ]
|
2015-06-25 18:35:18 +00:00
|
|
|
);
|
2015-02-17 17:03:23 +00:00
|
|
|
|
|
|
|
testGrid = [ 123, 456 ];
|
|
|
|
testModel = {
|
|
|
|
composition: ['a', 'b', 'c'],
|
|
|
|
layoutGrid: testGrid
|
|
|
|
};
|
|
|
|
testValues = { a: 10, b: 42, c: 31.42 };
|
2015-02-20 00:24:45 +00:00
|
|
|
testConfiguration = { elements: [
|
|
|
|
{ type: "fixed.telemetry", id: 'a', x: 1, y: 1 },
|
|
|
|
{ type: "fixed.telemetry", id: 'b', x: 1, y: 1 },
|
|
|
|
{ type: "fixed.telemetry", id: 'c', x: 1, y: 1 }
|
|
|
|
]};
|
2015-02-17 17:03:23 +00:00
|
|
|
|
2015-09-09 23:52:46 +00:00
|
|
|
mockHandler.handle.andReturn(mockHandle);
|
|
|
|
mockHandle.getTelemetryObjects.andReturn(
|
2015-02-17 17:03:23 +00:00
|
|
|
testModel.composition.map(makeMockDomainObject)
|
|
|
|
);
|
2015-09-09 23:52:46 +00:00
|
|
|
mockHandle.getRangeValue.andCallFake(function (o) {
|
2015-02-17 17:03:23 +00:00
|
|
|
return testValues[o.getId()];
|
|
|
|
});
|
2015-09-09 23:52:46 +00:00
|
|
|
mockHandle.getDomainValue.andReturn(12321);
|
2015-02-17 17:03:23 +00:00
|
|
|
mockFormatter.formatRangeValue.andCallFake(function (v) {
|
|
|
|
return "Formatted " + v;
|
|
|
|
});
|
2015-02-19 18:22:12 +00:00
|
|
|
mockScope.model = testModel;
|
2015-02-20 00:24:45 +00:00
|
|
|
mockScope.configuration = testConfiguration;
|
2015-03-04 02:47:44 +00:00
|
|
|
mockScope.selection = jasmine.createSpyObj(
|
|
|
|
'selection',
|
2015-03-04 02:52:13 +00:00
|
|
|
[ 'select', 'get', 'selected', 'deselect', 'proxy' ]
|
2015-03-04 02:47:44 +00:00
|
|
|
);
|
2015-02-17 17:03:23 +00:00
|
|
|
|
|
|
|
controller = new FixedController(
|
|
|
|
mockScope,
|
2015-02-20 23:53:41 +00:00
|
|
|
mockQ,
|
|
|
|
mockDialogService,
|
2015-09-09 23:52:46 +00:00
|
|
|
mockHandler,
|
2015-02-17 17:03:23 +00:00
|
|
|
mockFormatter
|
|
|
|
);
|
2016-02-27 00:19:14 +00:00
|
|
|
|
|
|
|
findWatch("selection")(mockScope.selection);
|
2015-02-17 17:03:23 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("subscribes when a domain object is available", function () {
|
|
|
|
mockScope.domainObject = mockDomainObject;
|
|
|
|
findWatch("domainObject")(mockDomainObject);
|
2015-09-09 23:52:46 +00:00
|
|
|
expect(mockHandler.handle).toHaveBeenCalledWith(
|
2015-02-17 17:03:23 +00:00
|
|
|
mockDomainObject,
|
|
|
|
jasmine.any(Function)
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2015-02-20 00:24:45 +00:00
|
|
|
it("releases subscriptions when domain objects change", function () {
|
2015-02-17 17:03:23 +00:00
|
|
|
mockScope.domainObject = mockDomainObject;
|
|
|
|
|
|
|
|
// First pass - should simply should subscribe
|
|
|
|
findWatch("domainObject")(mockDomainObject);
|
2015-09-09 23:52:46 +00:00
|
|
|
expect(mockHandle.unsubscribe).not.toHaveBeenCalled();
|
|
|
|
expect(mockHandler.handle.calls.length).toEqual(1);
|
2015-02-17 17:03:23 +00:00
|
|
|
|
|
|
|
// Object changes - should unsubscribe then resubscribe
|
|
|
|
findWatch("domainObject")(mockDomainObject);
|
2015-09-09 23:52:46 +00:00
|
|
|
expect(mockHandle.unsubscribe).toHaveBeenCalled();
|
|
|
|
expect(mockHandler.handle.calls.length).toEqual(2);
|
2015-02-17 17:03:23 +00:00
|
|
|
});
|
|
|
|
|
2015-02-20 00:24:45 +00:00
|
|
|
it("exposes visible elements based on configuration", function () {
|
|
|
|
var elements;
|
|
|
|
|
2015-02-17 17:03:23 +00:00
|
|
|
mockScope.model = testModel;
|
2015-02-20 00:24:45 +00:00
|
|
|
testModel.modified = 1;
|
|
|
|
findWatch("model.modified")(testModel.modified);
|
|
|
|
|
|
|
|
elements = controller.getElements();
|
|
|
|
expect(elements.length).toEqual(3);
|
|
|
|
expect(elements[0].id).toEqual('a');
|
|
|
|
expect(elements[1].id).toEqual('b');
|
|
|
|
expect(elements[2].id).toEqual('c');
|
|
|
|
});
|
|
|
|
|
|
|
|
it("allows elements to be selected", function () {
|
|
|
|
var elements;
|
|
|
|
|
|
|
|
testModel.modified = 1;
|
|
|
|
findWatch("model.modified")(testModel.modified);
|
|
|
|
|
|
|
|
elements = controller.getElements();
|
|
|
|
controller.select(elements[1]);
|
2015-03-04 02:47:44 +00:00
|
|
|
expect(mockScope.selection.select)
|
|
|
|
.toHaveBeenCalledWith(elements[1]);
|
2015-02-20 00:24:45 +00:00
|
|
|
});
|
|
|
|
|
2015-02-24 18:12:33 +00:00
|
|
|
it("allows selection retrieval", function () {
|
|
|
|
// selected with no arguments should give the current
|
|
|
|
// selection
|
|
|
|
var elements;
|
|
|
|
|
|
|
|
testModel.modified = 1;
|
|
|
|
findWatch("model.modified")(testModel.modified);
|
|
|
|
|
|
|
|
elements = controller.getElements();
|
|
|
|
controller.select(elements[1]);
|
2015-03-04 23:08:11 +00:00
|
|
|
mockScope.selection.get.andReturn(elements[1]);
|
2015-02-24 18:12:33 +00:00
|
|
|
expect(controller.selected()).toEqual(elements[1]);
|
|
|
|
});
|
|
|
|
|
2015-02-20 00:24:45 +00:00
|
|
|
it("allows selections to be cleared", function () {
|
|
|
|
var elements;
|
|
|
|
|
|
|
|
testModel.modified = 1;
|
|
|
|
findWatch("model.modified")(testModel.modified);
|
|
|
|
|
|
|
|
elements = controller.getElements();
|
|
|
|
controller.select(elements[1]);
|
|
|
|
controller.clearSelection();
|
|
|
|
expect(controller.selected(elements[1])).toBeFalsy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("retains selections during refresh", function () {
|
|
|
|
// Get elements; remove one of them; trigger refresh.
|
|
|
|
// Same element (at least by index) should still be selected.
|
|
|
|
var elements;
|
|
|
|
|
|
|
|
testModel.modified = 1;
|
|
|
|
findWatch("model.modified")(testModel.modified);
|
|
|
|
|
|
|
|
elements = controller.getElements();
|
|
|
|
controller.select(elements[1]);
|
|
|
|
|
2015-03-04 02:47:44 +00:00
|
|
|
// Verify precondition
|
|
|
|
expect(mockScope.selection.select.calls.length).toEqual(1);
|
|
|
|
|
|
|
|
// Mimic selection behavior
|
|
|
|
mockScope.selection.get.andReturn(elements[1]);
|
|
|
|
|
2015-02-20 00:24:45 +00:00
|
|
|
elements[2].remove();
|
|
|
|
testModel.modified = 2;
|
|
|
|
findWatch("model.modified")(testModel.modified);
|
|
|
|
|
|
|
|
elements = controller.getElements();
|
|
|
|
// Verify removal, as test assumes this
|
|
|
|
expect(elements.length).toEqual(2);
|
|
|
|
|
2015-03-04 02:47:44 +00:00
|
|
|
expect(mockScope.selection.select.calls.length).toEqual(2);
|
2015-02-17 17:03:23 +00:00
|
|
|
});
|
|
|
|
|
2015-02-20 00:24:45 +00:00
|
|
|
it("provides values for telemetry elements", function () {
|
|
|
|
var elements;
|
2015-02-17 17:03:23 +00:00
|
|
|
// Initialize
|
|
|
|
mockScope.domainObject = mockDomainObject;
|
|
|
|
mockScope.model = testModel;
|
|
|
|
findWatch("domainObject")(mockDomainObject);
|
2015-02-20 00:24:45 +00:00
|
|
|
findWatch("model.modified")(1);
|
2015-02-17 18:34:13 +00:00
|
|
|
findWatch("model.composition")(mockScope.model.composition);
|
2015-02-17 17:03:23 +00:00
|
|
|
|
|
|
|
// Invoke the subscription callback
|
2015-09-09 23:52:46 +00:00
|
|
|
mockHandler.handle.mostRecentCall.args[1]();
|
2015-02-17 17:03:23 +00:00
|
|
|
|
2015-02-20 00:24:45 +00:00
|
|
|
// Get elements that controller is now exposing
|
|
|
|
elements = controller.getElements();
|
|
|
|
|
2015-02-17 17:03:23 +00:00
|
|
|
// Formatted values should be available
|
2015-02-20 00:24:45 +00:00
|
|
|
expect(elements[0].value).toEqual("Formatted 10");
|
|
|
|
expect(elements[1].value).toEqual("Formatted 42");
|
|
|
|
expect(elements[2].value).toEqual("Formatted 31.42");
|
2015-02-17 17:03:23 +00:00
|
|
|
});
|
|
|
|
|
2015-06-25 17:58:01 +00:00
|
|
|
it("updates elements styles when grid size changes", function () {
|
|
|
|
var originalLeft;
|
2015-02-17 17:03:23 +00:00
|
|
|
|
2015-06-25 17:58:01 +00:00
|
|
|
mockScope.domainObject = mockDomainObject;
|
2015-02-17 17:03:23 +00:00
|
|
|
mockScope.model = testModel;
|
2015-06-25 17:58:01 +00:00
|
|
|
findWatch("domainObject")(mockDomainObject);
|
|
|
|
findWatch("model.modified")(1);
|
2015-02-17 18:34:13 +00:00
|
|
|
findWatch("model.composition")(mockScope.model.composition);
|
2015-06-25 17:58:01 +00:00
|
|
|
findWatch("model.layoutGrid")([10, 10]);
|
|
|
|
originalLeft = controller.getElements()[0].style.left;
|
|
|
|
findWatch("model.layoutGrid")([20, 20]);
|
|
|
|
expect(controller.getElements()[0].style.left)
|
|
|
|
.not.toEqual(originalLeft);
|
2015-02-17 17:03:23 +00:00
|
|
|
});
|
2015-02-17 18:50:02 +00:00
|
|
|
|
2015-02-20 00:24:45 +00:00
|
|
|
it("listens for drop events", function () {
|
2015-02-17 18:50:02 +00:00
|
|
|
// Layout should position panels according to
|
|
|
|
// where the user dropped them, so it needs to
|
|
|
|
// listen for drop events.
|
|
|
|
expect(mockScope.$on).toHaveBeenCalledWith(
|
|
|
|
'mctDrop',
|
|
|
|
jasmine.any(Function)
|
|
|
|
);
|
|
|
|
|
|
|
|
// Verify precondition
|
2015-02-20 00:24:45 +00:00
|
|
|
expect(testConfiguration.elements.length).toEqual(3);
|
2015-02-17 18:50:02 +00:00
|
|
|
|
|
|
|
// Notify that a drop occurred
|
|
|
|
testModel.composition.push('d');
|
|
|
|
findOn('mctDrop')(
|
2015-06-25 18:35:18 +00:00
|
|
|
mockEvent,
|
2015-02-17 18:50:02 +00:00
|
|
|
'd',
|
|
|
|
{ x: 300, y: 100 }
|
|
|
|
);
|
2015-02-20 00:24:45 +00:00
|
|
|
|
|
|
|
// Should have added an element
|
|
|
|
expect(testConfiguration.elements.length).toEqual(4);
|
2015-02-17 18:50:02 +00:00
|
|
|
|
2015-06-25 18:35:18 +00:00
|
|
|
// ...and prevented default...
|
|
|
|
expect(mockEvent.preventDefault).toHaveBeenCalled();
|
|
|
|
|
2015-02-17 18:50:02 +00:00
|
|
|
// Should have triggered commit (provided by
|
|
|
|
// EditRepresenter) with some message.
|
|
|
|
expect(mockScope.commit)
|
|
|
|
.toHaveBeenCalledWith(jasmine.any(String));
|
|
|
|
});
|
2015-02-20 00:24:45 +00:00
|
|
|
|
2015-06-25 18:35:18 +00:00
|
|
|
it("ignores drops when default has been prevented", function () {
|
|
|
|
// Avoids redundant drop-handling, WTD-1233
|
2015-06-26 18:53:45 +00:00
|
|
|
mockEvent.defaultPrevented = true;
|
2015-06-25 18:35:18 +00:00
|
|
|
|
|
|
|
// Notify that a drop occurred
|
|
|
|
testModel.composition.push('d');
|
|
|
|
findOn('mctDrop')(
|
|
|
|
mockEvent,
|
|
|
|
'd',
|
|
|
|
{ x: 300, y: 100 }
|
|
|
|
);
|
|
|
|
|
|
|
|
// Should NOT have added an element
|
|
|
|
expect(testConfiguration.elements.length).toEqual(3);
|
|
|
|
});
|
|
|
|
|
2015-02-20 00:24:45 +00:00
|
|
|
it("unsubscribes when destroyed", function () {
|
|
|
|
// Make an object available
|
|
|
|
findWatch('domainObject')(mockDomainObject);
|
|
|
|
// Also verify precondition
|
2015-09-09 23:52:46 +00:00
|
|
|
expect(mockHandle.unsubscribe).not.toHaveBeenCalled();
|
2015-02-20 00:24:45 +00:00
|
|
|
// Destroy the scope
|
|
|
|
findOn('$destroy')();
|
|
|
|
// Should have unsubscribed
|
2015-09-09 23:52:46 +00:00
|
|
|
expect(mockHandle.unsubscribe).toHaveBeenCalled();
|
2015-02-20 00:24:45 +00:00
|
|
|
});
|
2015-02-20 23:59:22 +00:00
|
|
|
|
|
|
|
it("exposes its grid size", function () {
|
2015-06-25 17:58:01 +00:00
|
|
|
findWatch('model.layoutGrid')(testGrid);
|
2015-02-20 23:59:22 +00:00
|
|
|
// Template needs to be able to pass this into line
|
|
|
|
// elements to size SVGs appropriately
|
|
|
|
expect(controller.getGridSize()).toEqual(testGrid);
|
|
|
|
});
|
2015-03-04 02:52:13 +00:00
|
|
|
|
|
|
|
it("exposes a view-level selection proxy", function () {
|
|
|
|
expect(mockScope.selection.proxy).toHaveBeenCalledWith(
|
|
|
|
jasmine.any(Object)
|
|
|
|
);
|
|
|
|
});
|
2015-03-04 23:08:11 +00:00
|
|
|
|
2015-02-24 18:12:33 +00:00
|
|
|
it("exposes drag handles", function () {
|
|
|
|
var handles;
|
|
|
|
|
|
|
|
// Select something so that drag handles are expected
|
|
|
|
testModel.modified = 1;
|
|
|
|
findWatch("model.modified")(testModel.modified);
|
|
|
|
controller.select(controller.getElements()[1]);
|
|
|
|
|
|
|
|
// Should have a non-empty array of handles
|
|
|
|
handles = controller.handles();
|
|
|
|
expect(handles).toEqual(jasmine.any(Array));
|
|
|
|
expect(handles.length).not.toEqual(0);
|
|
|
|
|
|
|
|
// And they should have start/continue/end drag methods
|
|
|
|
handles.forEach(function (handle) {
|
|
|
|
expect(handle.startDrag).toEqual(jasmine.any(Function));
|
|
|
|
expect(handle.continueDrag).toEqual(jasmine.any(Function));
|
|
|
|
expect(handle.endDrag).toEqual(jasmine.any(Function));
|
|
|
|
});
|
|
|
|
});
|
2015-02-24 20:02:43 +00:00
|
|
|
|
|
|
|
it("exposes a move handle", function () {
|
|
|
|
var handle;
|
|
|
|
|
|
|
|
// Select something so that drag handles are expected
|
|
|
|
testModel.modified = 1;
|
|
|
|
findWatch("model.modified")(testModel.modified);
|
|
|
|
controller.select(controller.getElements()[1]);
|
|
|
|
|
|
|
|
// Should have a move handle
|
|
|
|
handle = controller.moveHandle();
|
|
|
|
|
|
|
|
// And it should have start/continue/end drag methods
|
|
|
|
expect(handle.startDrag).toEqual(jasmine.any(Function));
|
|
|
|
expect(handle.continueDrag).toEqual(jasmine.any(Function));
|
|
|
|
expect(handle.endDrag).toEqual(jasmine.any(Function));
|
|
|
|
});
|
|
|
|
|
|
|
|
it("updates selection style during drag", function () {
|
|
|
|
var oldStyle;
|
|
|
|
|
|
|
|
// Select something so that drag handles are expected
|
|
|
|
testModel.modified = 1;
|
|
|
|
findWatch("model.modified")(testModel.modified);
|
|
|
|
controller.select(controller.getElements()[1]);
|
2015-03-04 23:08:11 +00:00
|
|
|
mockScope.selection.get.andReturn(controller.getElements()[1]);
|
2015-02-24 20:02:43 +00:00
|
|
|
|
|
|
|
// Get style
|
|
|
|
oldStyle = controller.selected().style;
|
|
|
|
|
|
|
|
// Start a drag gesture
|
|
|
|
controller.moveHandle().startDrag();
|
|
|
|
|
|
|
|
// Haven't moved yet; style shouldn't have updated yet
|
|
|
|
expect(controller.selected().style).toEqual(oldStyle);
|
|
|
|
|
|
|
|
// Drag a little
|
|
|
|
controller.moveHandle().continueDrag([ 1000, 100 ]);
|
|
|
|
|
|
|
|
// Style should have been updated
|
|
|
|
expect(controller.selected().style).not.toEqual(oldStyle);
|
|
|
|
});
|
2015-12-30 17:29:24 +00:00
|
|
|
|
|
|
|
describe("on display bounds changes", function () {
|
|
|
|
var testBounds;
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
testBounds = { start: 123, end: 321 };
|
|
|
|
mockScope.domainObject = mockDomainObject;
|
|
|
|
mockScope.model = testModel;
|
|
|
|
findWatch("domainObject")(mockDomainObject);
|
|
|
|
findWatch("model.modified")(testModel.modified);
|
|
|
|
findWatch("model.composition")(mockScope.model.composition);
|
|
|
|
findOn('telemetry:display:bounds')({}, testBounds);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("issues new requests", function () {
|
|
|
|
expect(mockHandle.request).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("requests only a single point", function () {
|
|
|
|
expect(mockHandle.request.mostRecentCall.args[0].size)
|
|
|
|
.toEqual(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("and after data has been received", function () {
|
|
|
|
var mockSeries,
|
|
|
|
testValue;
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
testValue = 12321;
|
|
|
|
|
|
|
|
mockSeries = jasmine.createSpyObj('series', [
|
|
|
|
'getPointCount',
|
|
|
|
'getDomainValue',
|
|
|
|
'getRangeValue'
|
|
|
|
]);
|
|
|
|
mockSeries.getPointCount.andReturn(1);
|
|
|
|
mockSeries.getRangeValue.andReturn(testValue);
|
|
|
|
|
|
|
|
// Fire the callback associated with the request
|
|
|
|
mockHandle.request.mostRecentCall.args[1](
|
|
|
|
mockHandle.getTelemetryObjects()[0],
|
|
|
|
mockSeries
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("updates displayed values", function () {
|
|
|
|
expect(controller.getElements()[0].value)
|
|
|
|
.toEqual("Formatted " + testValue);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-12-07 20:33:29 +00:00
|
|
|
it("reflects limit status", function () {
|
|
|
|
var elements;
|
|
|
|
|
|
|
|
mockHandle.getDatum.andReturn({});
|
|
|
|
mockHandle.getTelemetryObjects().forEach(function (mockObject) {
|
|
|
|
var id = mockObject.getId(),
|
|
|
|
mockLimitCapability =
|
|
|
|
jasmine.createSpyObj('limit-' + id, ['evaluate']);
|
|
|
|
|
|
|
|
mockObject.getCapability.andCallFake(function (key) {
|
|
|
|
return (key === 'limit') && mockLimitCapability;
|
|
|
|
});
|
|
|
|
|
|
|
|
mockLimitCapability.evaluate
|
|
|
|
.andReturn({ cssClass: 'alarm-' + id });
|
|
|
|
});
|
|
|
|
|
|
|
|
// Initialize
|
|
|
|
mockScope.domainObject = mockDomainObject;
|
|
|
|
mockScope.model = testModel;
|
|
|
|
findWatch("domainObject")(mockDomainObject);
|
|
|
|
findWatch("model.modified")(1);
|
|
|
|
findWatch("model.composition")(mockScope.model.composition);
|
|
|
|
|
|
|
|
// Invoke the subscription callback
|
|
|
|
mockHandler.handle.mostRecentCall.args[1]();
|
|
|
|
|
|
|
|
// Get elements that controller is now exposing
|
|
|
|
elements = controller.getElements();
|
|
|
|
|
|
|
|
// Limit-based CSS classes should be available
|
|
|
|
expect(elements[0].cssClass).toEqual("alarm-a");
|
|
|
|
expect(elements[1].cssClass).toEqual("alarm-b");
|
|
|
|
expect(elements[2].cssClass).toEqual("alarm-c");
|
|
|
|
});
|
2015-12-30 18:15:05 +00:00
|
|
|
|
2015-02-17 17:03:23 +00:00
|
|
|
});
|
|
|
|
}
|
2015-06-23 20:43:00 +00:00
|
|
|
);
|