mirror of
https://github.com/nasa/openmct.git
synced 2025-06-01 23:20:50 +00:00
conditionSet provider with tests
This commit is contained in:
parent
283599ddf5
commit
0664d480e6
@ -20,42 +20,46 @@
|
|||||||
* at runtime from the About dialog for additional information.
|
* 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';
|
import Vue from 'vue';
|
||||||
|
|
||||||
export default function ConditionSet(openmct) {
|
export default function ConditionSetViewProvider(openmct) {
|
||||||
return {
|
return {
|
||||||
key: 'conditionSet',
|
key: 'conditionSet.view',
|
||||||
name: 'Condition Set',
|
|
||||||
cssClass: 'icon-folder',
|
|
||||||
canView: function (domainObject) {
|
canView: function (domainObject) {
|
||||||
return domainObject.type === 'conditionSet';
|
return domainObject.type === 'conditionSet';
|
||||||
},
|
},
|
||||||
view: function (domainObject) {
|
canEdit: function (domainObject) {
|
||||||
|
return domainObject.type === 'conditionSet';
|
||||||
|
},
|
||||||
|
view: function (domainObject, objectPath) {
|
||||||
let component;
|
let component;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
show: function (element) {
|
show(container) {
|
||||||
component = new Vue({
|
component = new Vue({
|
||||||
el: element,
|
el: container,
|
||||||
components: {
|
components: {
|
||||||
ConditionSetComponent
|
ConditionSet
|
||||||
},
|
},
|
||||||
provide: {
|
provide: {
|
||||||
openmct,
|
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.$destroy();
|
||||||
component = undefined;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
priority: function () {
|
priority() {
|
||||||
return 1;
|
return 100;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -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>
|
<template>
|
||||||
<div><!--Stuff goes here--></div>
|
<div class="l-condition-set">
|
||||||
|
<!-- content goes here -->
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
inject: ['openmct', 'domainObject'],
|
props: {
|
||||||
data: function () {
|
domainObject: {
|
||||||
return {
|
type: Object,
|
||||||
currentDomainObject: this.domainObject
|
required: true
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
data() {
|
||||||
|
let domainObject = JSON.parse(JSON.stringify(this.domainObject));
|
||||||
|
return {
|
||||||
|
internalDomainObject: domainObject
|
||||||
|
};
|
||||||
|
},
|
||||||
|
inject: ['openmct']
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -23,14 +23,28 @@
|
|||||||
import { createOpenMct } from 'testTools';
|
import { createOpenMct } from 'testTools';
|
||||||
import ConditionSetPlugin from './plugin';
|
import ConditionSetPlugin from './plugin';
|
||||||
|
|
||||||
fdescribe('The plugin', () => {
|
describe('The plugin', () => {
|
||||||
let openmct;
|
let openmct;
|
||||||
let conditionSetDefinition;
|
let conditionSetDefinition;
|
||||||
|
let element;
|
||||||
|
let child;
|
||||||
|
|
||||||
|
beforeEach((done) => {
|
||||||
|
const appHolder = document.createElement('div');
|
||||||
|
appHolder.style.width = '640px';
|
||||||
|
appHolder.style.height = '480px';
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
openmct = createOpenMct();
|
openmct = createOpenMct();
|
||||||
|
|
||||||
|
element = document.createElement('div');
|
||||||
|
child = document.createElement('div');
|
||||||
|
element.appendChild(child);
|
||||||
|
|
||||||
openmct.install(new ConditionSetPlugin());
|
openmct.install(new ConditionSetPlugin());
|
||||||
conditionSetDefinition = openmct.types.get('conditionSet').definition;
|
conditionSetDefinition = openmct.types.get('conditionSet').definition;
|
||||||
|
|
||||||
|
openmct.on('start', done);
|
||||||
|
openmct.start(appHolder);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('defines an object type with the correct key', () => {
|
it('defines an object type with the correct key', () => {
|
||||||
@ -41,11 +55,22 @@ fdescribe('The plugin', () => {
|
|||||||
expect(conditionSetDefinition.creatable).toBeTrue();
|
expect(conditionSetDefinition.creatable).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('The object', () => {
|
fit('provides a view', () => {
|
||||||
it('initializes with an empty composition list', () => {
|
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 = {
|
let mockDomainObject = {
|
||||||
identifier: {
|
identifier: {
|
||||||
key: 'testConditionSetKey',
|
key: 'test-key',
|
||||||
namespace: ''
|
namespace: ''
|
||||||
},
|
},
|
||||||
type: 'conditionSet'
|
type: 'conditionSet'
|
||||||
@ -56,4 +81,5 @@ fdescribe('The plugin', () => {
|
|||||||
expect(mockDomainObject.composition.length).toEqual(0);
|
expect(mockDomainObject.composition.length).toEqual(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user