mirror of
https://github.com/nasa/openmct.git
synced 2025-01-31 16:36:13 +00:00
add test
This commit is contained in:
parent
51c9328dfd
commit
4b13cbdb33
@ -30,7 +30,6 @@ export default class NewFolderAction {
|
||||
this.cssClass = 'icon-folder';
|
||||
|
||||
this._openmct = openmct;
|
||||
this._dialogService = openmct.$injector.get('dialogService');
|
||||
this._folderType = openmct.types.get('folder');
|
||||
this._dialogForm = {
|
||||
name: "New Folder Name",
|
||||
@ -51,9 +50,11 @@ export default class NewFolderAction {
|
||||
invoke(objectPath) {
|
||||
let domainObject = objectPath[0],
|
||||
parentKeystring = this._openmct.objects.makeKeyString(domainObject.identifier),
|
||||
composition = this._openmct.composition.get(domainObject);
|
||||
composition = this._openmct.composition.get(domainObject),
|
||||
dialogService = this._openmct.$injector.get('dialogService'),
|
||||
folderType = this._openmct.types.get('folder');
|
||||
|
||||
this._dialogService.getUserInput(this._dialogForm, {}).then((userInput) => {
|
||||
dialogService.getUserInput(this._dialogForm, {}).then((userInput) => {
|
||||
let name = userInput.name,
|
||||
identifier = {
|
||||
key: uuid(),
|
||||
@ -65,8 +66,8 @@ export default class NewFolderAction {
|
||||
location: parentKeystring
|
||||
};
|
||||
|
||||
this._folderType.definition.initialize(objectModel);
|
||||
objectModel.name = name;
|
||||
folderType.definition.initialize(objectModel);
|
||||
objectModel.name = name || 'New Folder';
|
||||
|
||||
this._openmct.objects.mutate(objectModel, 'created', Date.now());
|
||||
composition.add(objectModel);
|
||||
|
@ -23,8 +23,6 @@ import NewFolderAction from './newFolderAction';
|
||||
|
||||
export default function () {
|
||||
return function (openmct) {
|
||||
openmct.on('start', () => {
|
||||
openmct.contextMenu.registerAction(new NewFolderAction(openmct));
|
||||
});
|
||||
openmct.contextMenu.registerAction(new NewFolderAction(openmct));
|
||||
};
|
||||
}
|
||||
|
51
src/plugins/newFolderAction/pluginSpec.js
Normal file
51
src/plugins/newFolderAction/pluginSpec.js
Normal file
@ -0,0 +1,51 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2020, 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 {
|
||||
createOpenMct,
|
||||
createMouseEvent,
|
||||
spyOnBuiltins,
|
||||
resetApplicationState
|
||||
} from 'utils/testing';
|
||||
|
||||
fdescribe("the plugin", () => {
|
||||
let openmct,
|
||||
newFolderAction;
|
||||
|
||||
beforeAll(() => {
|
||||
resetApplicationState();
|
||||
});
|
||||
|
||||
beforeEach((done) => {
|
||||
openmct = createOpenMct();
|
||||
|
||||
openmct.on('start', done);
|
||||
openmct.startHeadless();
|
||||
|
||||
newFolderAction = openmct.contextMenu._allActions.filter(action => {
|
||||
return action.key === 'newFolder';
|
||||
})[0];
|
||||
});
|
||||
|
||||
it('installs the new folder action', () => {
|
||||
expect(newFolderAction).toBeDefined();
|
||||
});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user