add test
This commit is contained in:
@@ -30,7 +30,6 @@ export default class NewFolderAction {
|
|||||||
this.cssClass = 'icon-folder';
|
this.cssClass = 'icon-folder';
|
||||||
|
|
||||||
this._openmct = openmct;
|
this._openmct = openmct;
|
||||||
this._dialogService = openmct.$injector.get('dialogService');
|
|
||||||
this._folderType = openmct.types.get('folder');
|
this._folderType = openmct.types.get('folder');
|
||||||
this._dialogForm = {
|
this._dialogForm = {
|
||||||
name: "New Folder Name",
|
name: "New Folder Name",
|
||||||
@@ -51,9 +50,11 @@ export default class NewFolderAction {
|
|||||||
invoke(objectPath) {
|
invoke(objectPath) {
|
||||||
let domainObject = objectPath[0],
|
let domainObject = objectPath[0],
|
||||||
parentKeystring = this._openmct.objects.makeKeyString(domainObject.identifier),
|
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,
|
let name = userInput.name,
|
||||||
identifier = {
|
identifier = {
|
||||||
key: uuid(),
|
key: uuid(),
|
||||||
@@ -65,8 +66,8 @@ export default class NewFolderAction {
|
|||||||
location: parentKeystring
|
location: parentKeystring
|
||||||
};
|
};
|
||||||
|
|
||||||
this._folderType.definition.initialize(objectModel);
|
folderType.definition.initialize(objectModel);
|
||||||
objectModel.name = name;
|
objectModel.name = name || 'New Folder';
|
||||||
|
|
||||||
this._openmct.objects.mutate(objectModel, 'created', Date.now());
|
this._openmct.objects.mutate(objectModel, 'created', Date.now());
|
||||||
composition.add(objectModel);
|
composition.add(objectModel);
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ import NewFolderAction from './newFolderAction';
|
|||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
return function (openmct) {
|
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();
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user