Added tests for ConditionPlugin

This commit is contained in:
Joel McKinnon 2019-12-16 14:42:19 -08:00
parent 5df74aee68
commit 221e5b4f6c
2 changed files with 50 additions and 13 deletions

View File

@ -20,8 +20,6 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
import ConditionViewProvider from './ConditionViewProvider';
export default function ConditionPlugin() {
const conditionType = {
name: 'Condition',
@ -35,8 +33,6 @@ export default function ConditionPlugin() {
};
return function install(openmct) {
openmct.objectViews.addProvider(new ConditionViewProvider(openmct));
openmct.types.addType('condition', conditionType);
};
}

View File

@ -1,20 +1,61 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2018, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT 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 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.
*****************************************************************************/
import ConditionPlugin from './plugin';
import {
createOpenMct
} from 'testTools';
import { createOpenMct } from 'testTools';
describe("The condition object plugin", function () {
fdescribe("The plugin", () => {
let openmct;
let conditionType;
let mockDomainObject;
beforeEach(() => {
mockDomainObject = {};
beforeEach(function () {
openmct = createOpenMct();
openmct.install(new ConditionPlugin());
conditionType = openmct.types.get('condition');
});
fit('shows the object exists', () => {
const install = new ConditionPlugin();
install(openmct);
const conditionType = openmct.types.get('condition');
it('defines a condition object with the correct name', () => {
expect(conditionType.definition.name).toEqual('Condition');
});
it('defines a condition object that is creatable', () => {
expect(conditionType.definition.creatable).toBeTrue();
});
describe("shows the condition object is initialized with", () => {
beforeEach(() => {
conditionType.definition.initialize(mockDomainObject);
});
it('a composition array', () => {
expect(Array.isArray(mockDomainObject.composition)).toBeTrue();
});
it('a telemetry object', () => {
expect(typeof mockDomainObject.telemetry === 'object').toBeTrue();
});
});
});