conditionSet provider with tests

This commit is contained in:
Joel McKinnon 2019-12-23 11:19:56 -08:00
parent 283599ddf5
commit 0664d480e6
3 changed files with 90 additions and 28 deletions

View File

@ -20,42 +20,46 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
import ConditionSetComponent from './components/ConditionSet.vue';
import ConditionSet from './components/ConditionSet.vue';
import Vue from 'vue';
export default function ConditionSet(openmct) {
export default function ConditionSetViewProvider(openmct) {
return {
key: 'conditionSet',
name: 'Condition Set',
cssClass: 'icon-folder',
key: 'conditionSet.view',
canView: function (domainObject) {
return domainObject.type === 'conditionSet';
},
view: function (domainObject) {
canEdit: function (domainObject) {
return domainObject.type === 'conditionSet';
},
view: function (domainObject, objectPath) {
let component;
return {
show: function (element) {
component = new Vue({
el: element,
show(container) {
component = new Vue({
el: container,
components: {
ConditionSetComponent
ConditionSet
},
provide: {
openmct,
domainObject
objectPath
},
template: '<condition-set-component></condition-set-component>'
data() {
return {
domainObject
};
},
template: '<condition-set ref="conditionSet" :domain-object="domainObject"></condition-set>'
});
},
destroy: function (element) {
destroy() {
component.$destroy();
component = undefined;
}
};
},
priority: function () {
return 1;
priority() {
return 100;
}
};
}

View File

@ -1,14 +1,46 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2019, 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.
*****************************************************************************/
<template>
<div><!--Stuff goes here--></div>
<div class="l-condition-set">
<!-- content goes here -->
</div>
</template>
<script>
export default {
inject: ['openmct', 'domainObject'],
data: function () {
return {
currentDomainObject: this.domainObject
props: {
domainObject: {
type: Object,
required: true
}
}
},
data() {
let domainObject = JSON.parse(JSON.stringify(this.domainObject));
return {
internalDomainObject: domainObject
};
},
inject: ['openmct']
}
</script>

View File

@ -23,14 +23,28 @@
import { createOpenMct } from 'testTools';
import ConditionSetPlugin from './plugin';
fdescribe('The plugin', () => {
describe('The plugin', () => {
let openmct;
let conditionSetDefinition;
let element;
let child;
beforeEach((done) => {
const appHolder = document.createElement('div');
appHolder.style.width = '640px';
appHolder.style.height = '480px';
beforeEach(() => {
openmct = createOpenMct();
element = document.createElement('div');
child = document.createElement('div');
element.appendChild(child);
openmct.install(new ConditionSetPlugin());
conditionSetDefinition = openmct.types.get('conditionSet').definition;
openmct.on('start', done);
openmct.start(appHolder);
});
it('defines an object type with the correct key', () => {
@ -41,11 +55,22 @@ fdescribe('The plugin', () => {
expect(conditionSetDefinition.creatable).toBeTrue();
});
describe('The object', () => {
it('initializes with an empty composition list', () => {
fit('provides a view', () => {
const testViewObject = {
id:"test-object",
type: "conditionSet"
};
const applicableViews = openmct.objectViews.get(testViewObject);
let conditionSetView = applicableViews.find((viewProvider) => viewProvider.key === 'conditionSet.view');
expect(conditionSetView).toBeDefined();
});
describe('provides an object', () => {
it('which initializes with an empty composition list', () => {
let mockDomainObject = {
identifier: {
key: 'testConditionSetKey',
key: 'test-key',
namespace: ''
},
type: 'conditionSet'
@ -56,4 +81,5 @@ fdescribe('The plugin', () => {
expect(mockDomainObject.composition.length).toEqual(0);
});
});
});