2015-05-13 23:42:35 +00:00
|
|
|
/*****************************************************************************
|
2018-05-14 22:46:17 +00:00
|
|
|
* Open MCT, Copyright (c) 2014-2018, United States Government
|
2015-05-13 23:42:35 +00:00
|
|
|
* as represented by the Administrator of the National Aeronautics and Space
|
|
|
|
* Administration. All rights reserved.
|
|
|
|
*
|
2016-07-12 23:21:58 +00:00
|
|
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
2015-05-13 23:42:35 +00:00
|
|
|
* "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.
|
|
|
|
*
|
2016-07-12 23:21:58 +00:00
|
|
|
* Open MCT includes source code licensed under additional open source
|
2015-05-13 23:42:35 +00:00
|
|
|
* 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-17 20:58:36 +00:00
|
|
|
|
|
|
|
define(
|
|
|
|
['../../src/representers/EditToolbar'],
|
|
|
|
function (EditToolbar) {
|
|
|
|
|
|
|
|
describe("An Edit mode toolbar", function () {
|
2018-06-27 20:30:01 +00:00
|
|
|
var mockOpenMCT,
|
|
|
|
mockScope,
|
|
|
|
mockObjects,
|
|
|
|
mockDomainObject,
|
2015-02-24 03:47:56 +00:00
|
|
|
testStructure,
|
2015-02-17 20:58:36 +00:00
|
|
|
testAB,
|
|
|
|
testABC,
|
|
|
|
testABC2,
|
|
|
|
testABCXYZ,
|
2015-02-19 20:44:00 +00:00
|
|
|
testABCYZ,
|
2015-02-24 03:47:56 +00:00
|
|
|
testM,
|
|
|
|
toolbar;
|
|
|
|
|
2015-02-17 20:58:36 +00:00
|
|
|
beforeEach(function () {
|
2018-06-27 20:30:01 +00:00
|
|
|
mockOpenMCT = jasmine.createSpy('openmct', ['objects']);
|
|
|
|
mockObjects = jasmine.createSpyObj('objects', ['observe']);
|
|
|
|
mockObjects.observe.andReturn();
|
|
|
|
mockOpenMCT.objects = mockObjects;
|
|
|
|
mockScope = jasmine.createSpyObj("$scope", [
|
|
|
|
"$watchCollection",
|
|
|
|
"$on"
|
|
|
|
]);
|
|
|
|
mockScope.$watchCollection.andReturn();
|
|
|
|
mockDomainObject = jasmine.createSpyObj("domainObject", [
|
|
|
|
'identifier'
|
|
|
|
]);
|
|
|
|
|
|
|
|
testStructure = [
|
|
|
|
{ name: "A", property: "a", domainObject: mockDomainObject },
|
|
|
|
{ name: "B", property: "b", domainObject: mockDomainObject },
|
|
|
|
{ name: "C", property: "c", domainObject: mockDomainObject },
|
|
|
|
{ name: "X", property: "x", domainObject: mockDomainObject },
|
|
|
|
{ name: "Y", property: "y", domainObject: mockDomainObject },
|
|
|
|
{ name: "Z", property: "z", domainObject: mockDomainObject },
|
|
|
|
{ name: "M", method: "m", domainObject: mockDomainObject }
|
|
|
|
];
|
|
|
|
|
2015-02-17 20:58:36 +00:00
|
|
|
testAB = { a: 0, b: 1 };
|
|
|
|
testABC = { a: 0, b: 1, c: 2 };
|
|
|
|
testABC2 = { a: 4, b: 1, c: 2 }; // For inconsistent-state checking
|
2015-02-17 21:47:14 +00:00
|
|
|
testABCXYZ = { a: 0, b: 1, c: 2, x: 'X!', y: 'Y!', z: 'Z!' };
|
|
|
|
testABCYZ = { a: 0, b: 1, c: 2, y: 'Y!', z: 'Z!' };
|
2015-02-19 20:44:00 +00:00
|
|
|
testM = { m: jasmine.createSpy("method") };
|
2015-02-24 03:47:56 +00:00
|
|
|
|
2018-06-27 20:30:01 +00:00
|
|
|
toolbar = new EditToolbar(mockScope, mockOpenMCT, testStructure);
|
2015-02-17 20:58:36 +00:00
|
|
|
});
|
|
|
|
|
2018-06-27 20:30:01 +00:00
|
|
|
it("adds click functions when a method is specified", function () {
|
|
|
|
var structure = toolbar.getStructure();
|
|
|
|
expect(structure[6].click).toBeDefined();
|
2015-02-17 20:58:36 +00:00
|
|
|
});
|
2015-02-19 20:44:00 +00:00
|
|
|
|
2018-06-27 20:30:01 +00:00
|
|
|
it("adds key for controls that define a property", function () {
|
|
|
|
var structure = toolbar.getStructure();
|
|
|
|
expect(structure[0].key).toEqual(0);
|
2015-02-19 20:44:00 +00:00
|
|
|
});
|
2015-02-17 20:58:36 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
|