mirror of
https://github.com/nasa/openmct.git
synced 2025-06-09 10:51:39 +00:00
[Testing] Resolve all promises (#3829)
* all promises in test specs should be returned Co-authored-by: Shefali Joshi <simplyrender@gmail.com> Co-authored-by: Andrew Henry <akhenry@gmail.com>
This commit is contained in:
parent
9d8a8b36d2
commit
333e8b5583
@ -73,7 +73,7 @@ describe('the plugin', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('provides a folder to hold plans', () => {
|
it('provides a folder to hold plans', () => {
|
||||||
openmct.objects.get(identifier).then((object) => {
|
return openmct.objects.get(identifier).then((object) => {
|
||||||
expect(object).toEqual({
|
expect(object).toEqual({
|
||||||
identifier,
|
identifier,
|
||||||
type: 'folder',
|
type: 'folder',
|
||||||
@ -83,7 +83,7 @@ describe('the plugin', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('provides composition for couch search folders', () => {
|
it('provides composition for couch search folders', () => {
|
||||||
composition.load().then((objects) => {
|
return composition.load().then((objects) => {
|
||||||
expect(objects.length).toEqual(2);
|
expect(objects.length).toEqual(2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -67,10 +67,6 @@ describe("The LAD Table", () => {
|
|||||||
|
|
||||||
// this setups up the app
|
// this setups up the app
|
||||||
beforeEach((done) => {
|
beforeEach((done) => {
|
||||||
const appHolder = document.createElement('div');
|
|
||||||
appHolder.style.width = '640px';
|
|
||||||
appHolder.style.height = '480px';
|
|
||||||
|
|
||||||
openmct = createOpenMct();
|
openmct = createOpenMct();
|
||||||
|
|
||||||
parent = document.createElement('div');
|
parent = document.createElement('div');
|
||||||
@ -90,7 +86,7 @@ describe("The LAD Table", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
openmct.on('start', done);
|
openmct.on('start', done);
|
||||||
openmct.startHeadless(appHolder);
|
openmct.startHeadless();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -113,7 +109,8 @@ describe("The LAD Table", () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
ladTableCompositionCollection = openmct.composition.get(mockObj.ladTable);
|
ladTableCompositionCollection = openmct.composition.get(mockObj.ladTable);
|
||||||
ladTableCompositionCollection.load();
|
|
||||||
|
return ladTableCompositionCollection.load();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should accept telemetry producing objects", () => {
|
it("should accept telemetry producing objects", () => {
|
||||||
@ -192,8 +189,6 @@ describe("The LAD Table", () => {
|
|||||||
|
|
||||||
await Promise.all([telemetryRequestPromise, telemetryObjectPromise, anotherTelemetryObjectPromise]);
|
await Promise.all([telemetryRequestPromise, telemetryObjectPromise, anotherTelemetryObjectPromise]);
|
||||||
await Vue.nextTick();
|
await Vue.nextTick();
|
||||||
|
|
||||||
return;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show one row per object in the composition", () => {
|
it("should show one row per object in the composition", () => {
|
||||||
@ -242,13 +237,6 @@ describe("The LAD Table Set", () => {
|
|||||||
let ladPlugin;
|
let ladPlugin;
|
||||||
let parent;
|
let parent;
|
||||||
let child;
|
let child;
|
||||||
let telemetryCount = 3;
|
|
||||||
let timeFormat = 'utc';
|
|
||||||
|
|
||||||
let mockTelemetry = getMockTelemetry({
|
|
||||||
count: telemetryCount,
|
|
||||||
format: timeFormat
|
|
||||||
});
|
|
||||||
|
|
||||||
let mockObj = getMockObjects({
|
let mockObj = getMockObjects({
|
||||||
objectKeyStrings: ['ladTable', 'ladTableSet', 'telemetry']
|
objectKeyStrings: ['ladTable', 'ladTableSet', 'telemetry']
|
||||||
@ -264,31 +252,22 @@ describe("The LAD Table Set", () => {
|
|||||||
mockObj.ladTableSet.composition.push(mockObj.ladTable.identifier);
|
mockObj.ladTableSet.composition.push(mockObj.ladTable.identifier);
|
||||||
|
|
||||||
beforeEach((done) => {
|
beforeEach((done) => {
|
||||||
const appHolder = document.createElement('div');
|
|
||||||
|
|
||||||
appHolder.style.width = '640px';
|
|
||||||
appHolder.style.height = '480px';
|
|
||||||
|
|
||||||
openmct = createOpenMct();
|
openmct = createOpenMct();
|
||||||
|
|
||||||
parent = document.createElement('div');
|
parent = document.createElement('div');
|
||||||
child = document.createElement('div');
|
child = document.createElement('div');
|
||||||
parent.appendChild(child);
|
parent.appendChild(child);
|
||||||
|
|
||||||
spyOn(openmct.telemetry, 'request').and.returnValue(Promise.resolve([]));
|
|
||||||
|
|
||||||
ladPlugin = new LadPlugin();
|
ladPlugin = new LadPlugin();
|
||||||
openmct.install(ladPlugin);
|
openmct.install(ladPlugin);
|
||||||
|
|
||||||
spyOn(openmct.objects, 'get').and.returnValue(Promise.resolve({}));
|
|
||||||
|
|
||||||
openmct.time.bounds({
|
openmct.time.bounds({
|
||||||
start: bounds.start,
|
start: bounds.start,
|
||||||
end: bounds.end
|
end: bounds.end
|
||||||
});
|
});
|
||||||
|
|
||||||
openmct.on('start', done);
|
openmct.on('start', done);
|
||||||
openmct.start(appHolder);
|
openmct.startHeadless();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -301,6 +280,8 @@ describe("The LAD Table Set", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should provide a lad table set view only for lad table set objects", () => {
|
it("should provide a lad table set view only for lad table set objects", () => {
|
||||||
|
spyOn(openmct.objects, 'get').and.returnValue(Promise.resolve({}));
|
||||||
|
|
||||||
let applicableViews = openmct.objectViews.get(mockObj.ladTableSet, []);
|
let applicableViews = openmct.objectViews.get(mockObj.ladTableSet, []);
|
||||||
|
|
||||||
let ladTableSetView = applicableViews.find(
|
let ladTableSetView = applicableViews.find(
|
||||||
@ -315,8 +296,11 @@ describe("The LAD Table Set", () => {
|
|||||||
let ladTableSetCompositionCollection;
|
let ladTableSetCompositionCollection;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
spyOn(openmct.objects, 'get').and.returnValue(Promise.resolve({}));
|
||||||
|
|
||||||
ladTableSetCompositionCollection = openmct.composition.get(mockObj.ladTableSet);
|
ladTableSetCompositionCollection = openmct.composition.get(mockObj.ladTableSet);
|
||||||
ladTableSetCompositionCollection.load();
|
|
||||||
|
return ladTableSetCompositionCollection.load();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should accept lad table objects", () => {
|
it("should accept lad table objects", () => {
|
||||||
@ -354,41 +338,17 @@ describe("The LAD Table Set", () => {
|
|||||||
otherObj.ladTable.composition.push(mockObj.telemetry.identifier);
|
otherObj.ladTable.composition.push(mockObj.telemetry.identifier);
|
||||||
mockObj.ladTableSet.composition.push(otherObj.ladTable.identifier);
|
mockObj.ladTableSet.composition.push(otherObj.ladTable.identifier);
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(() => {
|
||||||
let telemetryRequestResolve;
|
spyOn(openmct.telemetry, 'request').and.returnValue(Promise.resolve([]));
|
||||||
let ladObjectResolve;
|
|
||||||
let anotherLadObjectResolve;
|
|
||||||
|
|
||||||
let telemetryRequestPromise = new Promise((resolve) => {
|
spyOn(openmct.objects, 'get').and.callFake((obj) => {
|
||||||
telemetryRequestResolve = resolve;
|
|
||||||
});
|
|
||||||
|
|
||||||
let ladObjectPromise = new Promise((resolve) => {
|
|
||||||
ladObjectResolve = resolve;
|
|
||||||
});
|
|
||||||
|
|
||||||
let anotherLadObjectPromise = new Promise((resolve) => {
|
|
||||||
anotherLadObjectResolve = resolve;
|
|
||||||
});
|
|
||||||
|
|
||||||
openmct.telemetry.request.and.callFake(() => {
|
|
||||||
telemetryRequestResolve(mockTelemetry);
|
|
||||||
|
|
||||||
return telemetryRequestPromise;
|
|
||||||
});
|
|
||||||
|
|
||||||
openmct.objects.get.and.callFake((obj) => {
|
|
||||||
if (obj.key === 'lad-object') {
|
if (obj.key === 'lad-object') {
|
||||||
ladObjectResolve(mockObj.ladObject);
|
return Promise.resolve(mockObj.ladTable);
|
||||||
|
|
||||||
return ladObjectPromise;
|
|
||||||
} else if (obj.key === 'another-lad-object') {
|
} else if (obj.key === 'another-lad-object') {
|
||||||
anotherLadObjectResolve(otherObj.ladObject);
|
return Promise.resolve(otherObj.ladTable);
|
||||||
|
} else if (obj.key === 'telemetry-object') {
|
||||||
return anotherLadObjectPromise;
|
return Promise.resolve(mockObj.telemetry);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.resolve({});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
openmct.time.bounds({
|
openmct.time.bounds({
|
||||||
@ -399,20 +359,19 @@ describe("The LAD Table Set", () => {
|
|||||||
applicableViews = openmct.objectViews.get(mockObj.ladTableSet, []);
|
applicableViews = openmct.objectViews.get(mockObj.ladTableSet, []);
|
||||||
ladTableSetViewProvider = applicableViews.find((viewProvider) => viewProvider.key === ladTableSetKey);
|
ladTableSetViewProvider = applicableViews.find((viewProvider) => viewProvider.key === ladTableSetKey);
|
||||||
ladTableSetView = ladTableSetViewProvider.view(mockObj.ladTableSet, [mockObj.ladTableSet]);
|
ladTableSetView = ladTableSetViewProvider.view(mockObj.ladTableSet, [mockObj.ladTableSet]);
|
||||||
ladTableSetView.show(child, true);
|
ladTableSetView.show(child);
|
||||||
|
|
||||||
await Promise.all([telemetryRequestPromise, ladObjectPromise, anotherLadObjectPromise]);
|
return Vue.nextTick();
|
||||||
await Vue.nextTick();
|
|
||||||
|
|
||||||
return;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show one row per lad table object in the composition", () => {
|
it("should show one row per lad table object in the composition", () => {
|
||||||
|
const ladTableSetCompositionCollection = openmct.composition.get(mockObj.ladTableSet);
|
||||||
|
|
||||||
|
return ladTableSetCompositionCollection.load().then(() => {
|
||||||
const rowCount = parent.querySelectorAll(LAD_SET_TABLE_HEADERS).length;
|
const rowCount = parent.querySelectorAll(LAD_SET_TABLE_HEADERS).length;
|
||||||
|
|
||||||
expect(rowCount).toBe(mockObj.ladTableSet.composition.length);
|
expect(rowCount).toBe(mockObj.ladTableSet.composition.length);
|
||||||
pending();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
@ -22,12 +22,14 @@
|
|||||||
|
|
||||||
define(
|
define(
|
||||||
[
|
[
|
||||||
|
"utils/testing",
|
||||||
"./URLIndicator",
|
"./URLIndicator",
|
||||||
"./URLIndicatorPlugin",
|
"./URLIndicatorPlugin",
|
||||||
"../../MCT",
|
"../../MCT",
|
||||||
"zepto"
|
"zepto"
|
||||||
],
|
],
|
||||||
function (
|
function (
|
||||||
|
testingUtils,
|
||||||
URLIndicator,
|
URLIndicator,
|
||||||
URLIndicatorPlugin,
|
URLIndicatorPlugin,
|
||||||
MCT,
|
MCT,
|
||||||
@ -44,7 +46,7 @@ define(
|
|||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
jasmine.clock().install();
|
jasmine.clock().install();
|
||||||
openmct = new MCT();
|
openmct = new testingUtils.createOpenMct();
|
||||||
spyOn(openmct.indicators, 'add');
|
spyOn(openmct.indicators, 'add');
|
||||||
spyOn($, 'ajax');
|
spyOn($, 'ajax');
|
||||||
$.ajax.and.callFake(function (options) {
|
$.ajax.and.callFake(function (options) {
|
||||||
@ -55,6 +57,8 @@ define(
|
|||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
$.ajax = defaultAjaxFunction;
|
$.ajax = defaultAjaxFunction;
|
||||||
jasmine.clock().uninstall();
|
jasmine.clock().uninstall();
|
||||||
|
|
||||||
|
return testingUtils.resetApplicationState(openmct);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("on initialization", function () {
|
describe("on initialization", function () {
|
||||||
|
@ -28,8 +28,10 @@ import {
|
|||||||
resetApplicationState,
|
resetApplicationState,
|
||||||
spyOnBuiltins
|
spyOnBuiltins
|
||||||
} from 'utils/testing';
|
} from 'utils/testing';
|
||||||
|
import Vue from 'vue';
|
||||||
|
|
||||||
describe("AutoflowTabularPlugin", () => {
|
// TODO lots of its without expects
|
||||||
|
xdescribe("AutoflowTabularPlugin", () => {
|
||||||
let testType;
|
let testType;
|
||||||
let testObject;
|
let testObject;
|
||||||
let mockmct;
|
let mockmct;
|
||||||
@ -51,7 +53,7 @@ describe("AutoflowTabularPlugin", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
resetApplicationState(mockmct);
|
return resetApplicationState(mockmct);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("installs a view provider", () => {
|
it("installs a view provider", () => {
|
||||||
@ -101,7 +103,7 @@ describe("AutoflowTabularPlugin", () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach((done) => {
|
beforeEach(() => {
|
||||||
callbacks = {};
|
callbacks = {};
|
||||||
|
|
||||||
spyOnBuiltins(['requestAnimationFrame']);
|
spyOnBuiltins(['requestAnimationFrame']);
|
||||||
@ -180,7 +182,7 @@ describe("AutoflowTabularPlugin", () => {
|
|||||||
view = provider.view(testObject);
|
view = provider.view(testObject);
|
||||||
view.show(testContainer);
|
view.show(testContainer);
|
||||||
|
|
||||||
return done();
|
return Vue.nextTick();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
@ -121,10 +121,9 @@ describe("The Duplicate Action plugin", () => {
|
|||||||
|
|
||||||
describe("when moving an object to a new parent", () => {
|
describe("when moving an object to a new parent", () => {
|
||||||
|
|
||||||
beforeEach(async (done) => {
|
beforeEach(async () => {
|
||||||
duplicateTask = new DuplicateTask(openmct);
|
duplicateTask = new DuplicateTask(openmct);
|
||||||
await duplicateTask.duplicate(parentObject, anotherParentObject);
|
await duplicateTask.duplicate(parentObject, anotherParentObject);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("the duplicate child object's name (when not changing) should be the same as the original object", async () => {
|
it("the duplicate child object's name (when not changing) should be the same as the original object", async () => {
|
||||||
@ -143,15 +142,15 @@ describe("The Duplicate Action plugin", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("when a new name is provided for the duplicated object", () => {
|
describe("when a new name is provided for the duplicated object", () => {
|
||||||
|
it("the name is updated", () => {
|
||||||
const NEW_NAME = 'New Name';
|
const NEW_NAME = 'New Name';
|
||||||
|
let childName;
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
duplicateTask = new DuplicateAction(openmct);
|
duplicateTask = new DuplicateAction(openmct);
|
||||||
duplicateTask.updateNameCheck(parentObject, NEW_NAME);
|
duplicateTask.updateNameCheck(parentObject, NEW_NAME);
|
||||||
});
|
|
||||||
|
|
||||||
it("the name is updated", () => {
|
childName = parentObject.name;
|
||||||
let childName = parentObject.name;
|
|
||||||
expect(childName).toEqual(NEW_NAME);
|
expect(childName).toEqual(NEW_NAME);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -24,10 +24,15 @@ import {
|
|||||||
resetApplicationState
|
resetApplicationState
|
||||||
} from 'utils/testing';
|
} from 'utils/testing';
|
||||||
|
|
||||||
describe("the plugin", () => {
|
describe("the goToOriginalAction plugin", () => {
|
||||||
let openmct;
|
let openmct;
|
||||||
let goToFolderAction;
|
let goToOriginalAction;
|
||||||
|
let mockRootFolder;
|
||||||
|
let mockSubFolder;
|
||||||
|
let mockSubSubFolder;
|
||||||
|
let mockObject;
|
||||||
let mockObjectPath;
|
let mockObjectPath;
|
||||||
|
let hash;
|
||||||
|
|
||||||
beforeEach((done) => {
|
beforeEach((done) => {
|
||||||
openmct = createOpenMct();
|
openmct = createOpenMct();
|
||||||
@ -35,7 +40,7 @@ describe("the plugin", () => {
|
|||||||
openmct.on('start', done);
|
openmct.on('start', done);
|
||||||
openmct.startHeadless();
|
openmct.startHeadless();
|
||||||
|
|
||||||
goToFolderAction = openmct.actions._allActions.goToOriginal;
|
goToOriginalAction = openmct.actions._allActions.goToOriginal;
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -43,34 +48,153 @@ describe("the plugin", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('installs the go to folder action', () => {
|
it('installs the go to folder action', () => {
|
||||||
expect(goToFolderAction).toBeDefined();
|
expect(goToOriginalAction).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when invoked', () => {
|
describe('when invoked', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockObjectPath = [{
|
mockRootFolder = getMockObject('mock-root');
|
||||||
name: 'mock folder',
|
mockSubFolder = getMockObject('mock-sub');
|
||||||
type: 'folder',
|
mockSubSubFolder = getMockObject('mock-sub-sub');
|
||||||
identifier: {
|
mockObject = getMockObject('mock-table');
|
||||||
key: 'mock-folder',
|
|
||||||
namespace: ''
|
|
||||||
}
|
|
||||||
}];
|
|
||||||
spyOn(openmct.objects, 'get').and.returnValue(Promise.resolve({
|
|
||||||
identifier: {
|
|
||||||
namespace: '',
|
|
||||||
key: 'test'
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
goToFolderAction.invoke(mockObjectPath);
|
mockObjectPath = [
|
||||||
|
mockObject,
|
||||||
|
mockSubSubFolder,
|
||||||
|
mockSubFolder,
|
||||||
|
mockRootFolder
|
||||||
|
];
|
||||||
|
|
||||||
|
spyOn(openmct.objects, 'get').and.callFake(identifier => {
|
||||||
|
const mockedObject = getMockObject(identifier);
|
||||||
|
|
||||||
|
return Promise.resolve(mockedObject);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('goes to the original location', (done) => {
|
spyOn(openmct.router, 'navigate').and.callFake(navigateTo => {
|
||||||
setTimeout(() => {
|
hash = navigateTo;
|
||||||
expect(window.location.href).toContain('context.html#/browse/?tc.mode=fixed&tc.startBound=0&tc.endBound=1&tc.timeSystem=utc');
|
});
|
||||||
done();
|
|
||||||
}, 1500);
|
return goToOriginalAction.invoke(mockObjectPath);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('goes to the original location', () => {
|
||||||
|
const originalLocationHash = '#/browse/mock-root/mock-table';
|
||||||
|
|
||||||
|
return waitForNavigation(() => {
|
||||||
|
return hash === originalLocationHash;
|
||||||
|
}).then(() => {
|
||||||
|
expect(hash).toEqual(originalLocationHash);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function waitForNavigation(navigated) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const start = Date.now();
|
||||||
|
|
||||||
|
checkNavigated();
|
||||||
|
|
||||||
|
function checkNavigated() {
|
||||||
|
const elapsed = Date.now() - start;
|
||||||
|
|
||||||
|
if (navigated()) {
|
||||||
|
resolve();
|
||||||
|
} else if (elapsed >= jasmine.DEFAULT_TIMEOUT_INTERVAL - 1000) {
|
||||||
|
reject("didn't navigate in time");
|
||||||
|
} else {
|
||||||
|
setTimeout(checkNavigated);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMockObject(key) {
|
||||||
|
const id = typeof key === 'string' ? key : key.key;
|
||||||
|
|
||||||
|
const mockMCTObjects = {
|
||||||
|
"ROOT": {
|
||||||
|
"composition": [
|
||||||
|
{
|
||||||
|
"namespace": "",
|
||||||
|
"key": "mock-root"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"identifier": {
|
||||||
|
"namespace": "",
|
||||||
|
"key": "mock-root"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mock-root": {
|
||||||
|
"composition": [
|
||||||
|
{
|
||||||
|
"namespace": "",
|
||||||
|
"key": "mock-sub"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"namespace": "",
|
||||||
|
"key": "mock-table"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "root",
|
||||||
|
"type": "folder",
|
||||||
|
"id": "mock-root",
|
||||||
|
"location": "ROOT",
|
||||||
|
"identifier": {
|
||||||
|
"namespace": "",
|
||||||
|
"key": "mock-root"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mock-sub": {
|
||||||
|
"composition": [
|
||||||
|
{
|
||||||
|
"namespace": "",
|
||||||
|
"key": "mock-sub-sub"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"namespace": "",
|
||||||
|
"key": "mock-table"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "sub",
|
||||||
|
"type": "folder",
|
||||||
|
"location": "mock-root",
|
||||||
|
"identifier": {
|
||||||
|
"namespace": "",
|
||||||
|
"key": "mock-sub"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mock-table": {
|
||||||
|
"composition": [],
|
||||||
|
"configuration": {
|
||||||
|
"columnWidths": {},
|
||||||
|
"hiddenColumns": {}
|
||||||
|
},
|
||||||
|
"name": "table",
|
||||||
|
"type": "table",
|
||||||
|
"location": "mock-root",
|
||||||
|
"identifier": {
|
||||||
|
"namespace": "",
|
||||||
|
"key": "mock-table"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mock-sub-sub": {
|
||||||
|
"composition": [
|
||||||
|
{
|
||||||
|
"namespace": "",
|
||||||
|
"key": "mock-table"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "sub sub",
|
||||||
|
"type": "folder",
|
||||||
|
"location": "mock-sub",
|
||||||
|
"identifier": {
|
||||||
|
"namespace": "",
|
||||||
|
"key": "mock-sub-sub"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return mockMCTObjects[id];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
@ -30,10 +30,6 @@ describe('the plugin', function () {
|
|||||||
const TEST_NAMESPACE = 'test';
|
const TEST_NAMESPACE = 'test';
|
||||||
|
|
||||||
beforeEach((done) => {
|
beforeEach((done) => {
|
||||||
const appHolder = document.createElement('div');
|
|
||||||
appHolder.style.width = '640px';
|
|
||||||
appHolder.style.height = '480px';
|
|
||||||
|
|
||||||
openmct = createOpenMct();
|
openmct = createOpenMct();
|
||||||
openmct.install(new InterceptorPlugin(openmct));
|
openmct.install(new InterceptorPlugin(openmct));
|
||||||
|
|
||||||
@ -46,7 +42,7 @@ describe('the plugin', function () {
|
|||||||
element.appendChild(child);
|
element.appendChild(child);
|
||||||
|
|
||||||
openmct.on('start', done);
|
openmct.on('start', done);
|
||||||
openmct.startHeadless(appHolder);
|
openmct.startHeadless();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -55,6 +51,7 @@ describe('the plugin', function () {
|
|||||||
|
|
||||||
describe('the missingObjectInterceptor', () => {
|
describe('the missingObjectInterceptor', () => {
|
||||||
let mockProvider;
|
let mockProvider;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockProvider = jasmine.createSpyObj("mock provider", [
|
mockProvider = jasmine.createSpyObj("mock provider", [
|
||||||
"get"
|
"get"
|
||||||
@ -63,27 +60,28 @@ describe('the plugin', function () {
|
|||||||
openmct.objects.addProvider(TEST_NAMESPACE, mockProvider);
|
openmct.objects.addProvider(TEST_NAMESPACE, mockProvider);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns missing objects', (done) => {
|
it('returns missing objects', () => {
|
||||||
const identifier = {
|
const identifier = {
|
||||||
namespace: TEST_NAMESPACE,
|
namespace: TEST_NAMESPACE,
|
||||||
key: 'hello'
|
key: 'hello'
|
||||||
};
|
};
|
||||||
openmct.objects.get(identifier).then((testObject) => {
|
|
||||||
|
return openmct.objects.get(identifier).then((testObject) => {
|
||||||
expect(testObject).toEqual({
|
expect(testObject).toEqual({
|
||||||
identifier,
|
identifier,
|
||||||
type: 'unknown',
|
type: 'unknown',
|
||||||
name: 'Missing: test:hello'
|
name: 'Missing: test:hello'
|
||||||
});
|
});
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns the My items object if not found', (done) => {
|
it('returns the My items object if not found', () => {
|
||||||
const identifier = {
|
const identifier = {
|
||||||
namespace: TEST_NAMESPACE,
|
namespace: TEST_NAMESPACE,
|
||||||
key: 'mine'
|
key: 'mine'
|
||||||
};
|
};
|
||||||
openmct.objects.get(identifier).then((testObject) => {
|
|
||||||
|
return openmct.objects.get(identifier).then((testObject) => {
|
||||||
expect(testObject).toEqual({
|
expect(testObject).toEqual({
|
||||||
identifier,
|
identifier,
|
||||||
"name": "My Items",
|
"name": "My Items",
|
||||||
@ -91,7 +89,6 @@ describe('the plugin', function () {
|
|||||||
"composition": [],
|
"composition": [],
|
||||||
"location": "ROOT"
|
"location": "ROOT"
|
||||||
});
|
});
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
* this source code distribution or the Licensing information page available
|
* this source code distribution or the Licensing information page available
|
||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
import MoveActionPlugin from './plugin.js';
|
|
||||||
import MoveAction from './MoveAction.js';
|
|
||||||
import {
|
import {
|
||||||
createOpenMct,
|
createOpenMct,
|
||||||
resetApplicationState,
|
resetApplicationState,
|
||||||
@ -37,10 +35,6 @@ describe("The Move Action plugin", () => {
|
|||||||
|
|
||||||
// this setups up the app
|
// this setups up the app
|
||||||
beforeEach((done) => {
|
beforeEach((done) => {
|
||||||
const appHolder = document.createElement('div');
|
|
||||||
appHolder.style.width = '640px';
|
|
||||||
appHolder.style.height = '480px';
|
|
||||||
|
|
||||||
openmct = createOpenMct();
|
openmct = createOpenMct();
|
||||||
|
|
||||||
childObject = getMockObjects({
|
childObject = getMockObjects({
|
||||||
@ -73,11 +67,10 @@ describe("The Move Action plugin", () => {
|
|||||||
}
|
}
|
||||||
}).folder;
|
}).folder;
|
||||||
|
|
||||||
// already installed by default, but never hurts, just adds to context menu
|
|
||||||
openmct.install(MoveActionPlugin());
|
|
||||||
|
|
||||||
openmct.on('start', done);
|
openmct.on('start', done);
|
||||||
openmct.startHeadless(appHolder);
|
openmct.startHeadless();
|
||||||
|
|
||||||
|
moveAction = openmct.actions._allActions.move;
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -85,13 +78,12 @@ describe("The Move Action plugin", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should be defined", () => {
|
it("should be defined", () => {
|
||||||
expect(MoveActionPlugin).toBeDefined();
|
expect(moveAction).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when moving an object to a new parent and removing from the old parent", () => {
|
describe("when moving an object to a new parent and removing from the old parent", () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
moveAction = new MoveAction(openmct);
|
|
||||||
moveAction.addToNewParent(childObject, anotherParentObject);
|
moveAction.addToNewParent(childObject, anotherParentObject);
|
||||||
moveAction.removeFromOldParent(parentObject, childObject);
|
moveAction.removeFromOldParent(parentObject, childObject);
|
||||||
});
|
});
|
||||||
|
@ -79,7 +79,7 @@ describe("the plugin", () => {
|
|||||||
spyOn(compositionAPI, 'get').and.returnValue(mockComposition);
|
spyOn(compositionAPI, 'get').and.returnValue(mockComposition);
|
||||||
spyOn(openmct.objects, 'save').and.returnValue(Promise.resolve(true));
|
spyOn(openmct.objects, 'save').and.returnValue(Promise.resolve(true));
|
||||||
|
|
||||||
newFolderAction.invoke(mockObjectPath);
|
return newFolderAction.invoke(mockObjectPath);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('gets user input for folder name', () => {
|
it('gets user input for folder name', () => {
|
||||||
|
@ -112,7 +112,7 @@ let openmct;
|
|||||||
let mockIdentifierService;
|
let mockIdentifierService;
|
||||||
|
|
||||||
describe('Notebook Entries:', () => {
|
describe('Notebook Entries:', () => {
|
||||||
beforeEach(done => {
|
beforeEach(() => {
|
||||||
openmct = createOpenMct();
|
openmct = createOpenMct();
|
||||||
openmct.$injector = jasmine.createSpyObj('$injector', ['get']);
|
openmct.$injector = jasmine.createSpyObj('$injector', ['get']);
|
||||||
mockIdentifierService = jasmine.createSpyObj(
|
mockIdentifierService = jasmine.createSpyObj(
|
||||||
@ -134,8 +134,6 @@ describe('Notebook Entries:', () => {
|
|||||||
'update'
|
'update'
|
||||||
]));
|
]));
|
||||||
window.localStorage.setItem('notebook-storage', null);
|
window.localStorage.setItem('notebook-storage', null);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -150,12 +148,11 @@ describe('Notebook Entries:', () => {
|
|||||||
expect(entries.length).toEqual(0);
|
expect(entries.length).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('addNotebookEntry adds entry', (done) => {
|
it('addNotebookEntry adds entry', () => {
|
||||||
const unlisten = openmct.objects.observe(notebookDomainObject, '*', (object) => {
|
const unlisten = openmct.objects.observe(notebookDomainObject, '*', (object) => {
|
||||||
const entries = NotebookEntries.getNotebookEntries(notebookDomainObject, selectedSection, selectedPage);
|
const entries = NotebookEntries.getNotebookEntries(notebookDomainObject, selectedSection, selectedPage);
|
||||||
|
|
||||||
expect(entries.length).toEqual(1);
|
expect(entries.length).toEqual(1);
|
||||||
done();
|
|
||||||
unlisten();
|
unlisten();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ let openmct;
|
|||||||
let mockIdentifierService;
|
let mockIdentifierService;
|
||||||
|
|
||||||
describe('Notebook Storage:', () => {
|
describe('Notebook Storage:', () => {
|
||||||
beforeEach((done) => {
|
beforeEach(() => {
|
||||||
openmct = createOpenMct();
|
openmct = createOpenMct();
|
||||||
openmct.$injector = jasmine.createSpyObj('$injector', ['get']);
|
openmct.$injector = jasmine.createSpyObj('$injector', ['get']);
|
||||||
mockIdentifierService = jasmine.createSpyObj(
|
mockIdentifierService = jasmine.createSpyObj(
|
||||||
@ -79,7 +79,6 @@ describe('Notebook Storage:', () => {
|
|||||||
'create',
|
'create',
|
||||||
'update'
|
'update'
|
||||||
]));
|
]));
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
@ -29,9 +29,10 @@ describe('the plugin', function () {
|
|||||||
let element;
|
let element;
|
||||||
let child;
|
let child;
|
||||||
let openmct;
|
let openmct;
|
||||||
|
let appHolder;
|
||||||
|
|
||||||
beforeEach((done) => {
|
beforeEach((done) => {
|
||||||
const appHolder = document.createElement('div');
|
appHolder = document.createElement('div');
|
||||||
appHolder.style.width = '640px';
|
appHolder.style.width = '640px';
|
||||||
appHolder.style.height = '480px';
|
appHolder.style.height = '480px';
|
||||||
|
|
||||||
@ -103,7 +104,7 @@ describe('the plugin', function () {
|
|||||||
];
|
];
|
||||||
let planView;
|
let planView;
|
||||||
|
|
||||||
beforeEach((done) => {
|
beforeEach(() => {
|
||||||
planDomainObject = {
|
planDomainObject = {
|
||||||
identifier: {
|
identifier: {
|
||||||
key: 'test-object',
|
key: 'test-object',
|
||||||
@ -140,9 +141,7 @@ describe('the plugin', function () {
|
|||||||
let view = planView.view(planDomainObject, mockObjectPath);
|
let view = planView.view(planDomainObject, mockObjectPath);
|
||||||
view.show(child, true);
|
view.show(child, true);
|
||||||
|
|
||||||
return Vue.nextTick().then(() => {
|
return Vue.nextTick();
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('loads activities into the view', () => {
|
it('loads activities into the view', () => {
|
||||||
|
@ -34,6 +34,7 @@ describe("the plugin", function () {
|
|||||||
let child;
|
let child;
|
||||||
let openmct;
|
let openmct;
|
||||||
let telemetryPromise;
|
let telemetryPromise;
|
||||||
|
let telemetryPromiseResolve;
|
||||||
let cleanupFirst;
|
let cleanupFirst;
|
||||||
let mockObjectPath;
|
let mockObjectPath;
|
||||||
let telemetrylimitProvider;
|
let telemetrylimitProvider;
|
||||||
@ -78,7 +79,6 @@ describe("the plugin", function () {
|
|||||||
|
|
||||||
openmct = createOpenMct();
|
openmct = createOpenMct();
|
||||||
|
|
||||||
let telemetryPromiseResolve;
|
|
||||||
telemetryPromise = new Promise((resolve) => {
|
telemetryPromise = new Promise((resolve) => {
|
||||||
telemetryPromiseResolve = resolve;
|
telemetryPromiseResolve = resolve;
|
||||||
});
|
});
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
* this source code distribution or the Licensing information page available
|
* this source code distribution or the Licensing information page available
|
||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
import RemoveActionPlugin from './plugin.js';
|
|
||||||
import RemoveAction from './RemoveAction.js';
|
|
||||||
import {
|
import {
|
||||||
createOpenMct,
|
createOpenMct,
|
||||||
resetApplicationState,
|
resetApplicationState,
|
||||||
@ -36,10 +34,6 @@ describe("The Remove Action plugin", () => {
|
|||||||
|
|
||||||
// this setups up the app
|
// this setups up the app
|
||||||
beforeEach((done) => {
|
beforeEach((done) => {
|
||||||
const appHolder = document.createElement('div');
|
|
||||||
appHolder.style.width = '640px';
|
|
||||||
appHolder.style.height = '480px';
|
|
||||||
|
|
||||||
openmct = createOpenMct();
|
openmct = createOpenMct();
|
||||||
|
|
||||||
childObject = getMockObjects({
|
childObject = getMockObjects({
|
||||||
@ -64,11 +58,10 @@ describe("The Remove Action plugin", () => {
|
|||||||
}
|
}
|
||||||
}).folder;
|
}).folder;
|
||||||
|
|
||||||
// already installed by default, but never hurts, just adds to context menu
|
|
||||||
openmct.install(RemoveActionPlugin());
|
|
||||||
|
|
||||||
openmct.on('start', done);
|
openmct.on('start', done);
|
||||||
openmct.startHeadless(appHolder);
|
openmct.startHeadless();
|
||||||
|
|
||||||
|
removeAction = openmct.actions._allActions.remove;
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -76,13 +69,12 @@ describe("The Remove Action plugin", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should be defined", () => {
|
it("should be defined", () => {
|
||||||
expect(RemoveActionPlugin).toBeDefined();
|
expect(removeAction).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when removing an object from a parent composition", () => {
|
describe("when removing an object from a parent composition", () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
removeAction = new RemoveAction(openmct);
|
|
||||||
spyOn(removeAction, 'removeFromComposition').and.callThrough();
|
spyOn(removeAction, 'removeFromComposition').and.callThrough();
|
||||||
spyOn(removeAction, 'inNavigationPath').and.returnValue(false);
|
spyOn(removeAction, 'inNavigationPath').and.returnValue(false);
|
||||||
spyOn(openmct.objects, 'mutate').and.callThrough();
|
spyOn(openmct.objects, 'mutate').and.callThrough();
|
||||||
@ -103,7 +95,6 @@ describe("The Remove Action plugin", () => {
|
|||||||
describe("when determining the object is applicable", () => {
|
describe("when determining the object is applicable", () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
removeAction = new RemoveAction(openmct);
|
|
||||||
spyOn(removeAction, 'appliesTo').and.callThrough();
|
spyOn(removeAction, 'appliesTo').and.callThrough();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ describe('the plugin', function () {
|
|||||||
let tabsLayoutViewProvider;
|
let tabsLayoutViewProvider;
|
||||||
let mockComposition;
|
let mockComposition;
|
||||||
|
|
||||||
beforeEach((done) => {
|
beforeEach(() => {
|
||||||
mockComposition = new EventEmitter();
|
mockComposition = new EventEmitter();
|
||||||
mockComposition.load = () => {
|
mockComposition.load = () => {
|
||||||
return Promise.resolve([telemetryItem1]);
|
return Promise.resolve([telemetryItem1]);
|
||||||
@ -125,7 +125,8 @@ describe('the plugin', function () {
|
|||||||
tabsLayoutViewProvider = applicableViews.find((viewProvider) => viewProvider.key === 'tabs');
|
tabsLayoutViewProvider = applicableViews.find((viewProvider) => viewProvider.key === 'tabs');
|
||||||
let view = tabsLayoutViewProvider.view(testViewObject, []);
|
let view = tabsLayoutViewProvider.view(testViewObject, []);
|
||||||
view.show(child, true);
|
view.show(child, true);
|
||||||
Vue.nextTick(done);
|
|
||||||
|
return Vue.nextTick();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('provides a view', () => {
|
it('provides a view', () => {
|
||||||
@ -150,7 +151,7 @@ describe('the plugin', function () {
|
|||||||
let mockComposition;
|
let mockComposition;
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
||||||
beforeEach((done) => {
|
beforeEach(() => {
|
||||||
mockComposition = new EventEmitter();
|
mockComposition = new EventEmitter();
|
||||||
mockComposition.load = () => {
|
mockComposition.load = () => {
|
||||||
if (count === 0) {
|
if (count === 0) {
|
||||||
@ -168,7 +169,8 @@ describe('the plugin', function () {
|
|||||||
tabsLayoutViewProvider = applicableViews.find((viewProvider) => viewProvider.key === 'tabs');
|
tabsLayoutViewProvider = applicableViews.find((viewProvider) => viewProvider.key === 'tabs');
|
||||||
let view = tabsLayoutViewProvider.view(testViewObject, []);
|
let view = tabsLayoutViewProvider.view(testViewObject, []);
|
||||||
view.show(child, true);
|
view.show(child, true);
|
||||||
Vue.nextTick(done);
|
|
||||||
|
return Vue.nextTick();
|
||||||
});
|
});
|
||||||
|
|
||||||
it ('renders a tab for each item', () => {
|
it ('renders a tab for each item', () => {
|
||||||
|
@ -50,9 +50,6 @@ describe('the plugin', function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
const appHolder = document.createElement('div');
|
|
||||||
appHolder.style.width = '640px';
|
|
||||||
appHolder.style.height = '480px';
|
|
||||||
|
|
||||||
openmct = createOpenMct();
|
openmct = createOpenMct();
|
||||||
openmct.install(new TimelinePlugin());
|
openmct.install(new TimelinePlugin());
|
||||||
@ -73,7 +70,7 @@ describe('the plugin', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
openmct.on('start', done);
|
openmct.on('start', done);
|
||||||
openmct.startHeadless(appHolder);
|
openmct.startHeadless();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -100,7 +97,7 @@ describe('the plugin', function () {
|
|||||||
describe('the view', () => {
|
describe('the view', () => {
|
||||||
let timelineView;
|
let timelineView;
|
||||||
|
|
||||||
beforeEach((done) => {
|
beforeEach(() => {
|
||||||
const testViewObject = {
|
const testViewObject = {
|
||||||
id: "test-object",
|
id: "test-object",
|
||||||
type: "time-strip"
|
type: "time-strip"
|
||||||
@ -110,7 +107,8 @@ describe('the plugin', function () {
|
|||||||
timelineView = applicableViews.find((viewProvider) => viewProvider.key === 'time-strip.view');
|
timelineView = applicableViews.find((viewProvider) => viewProvider.key === 'time-strip.view');
|
||||||
let view = timelineView.view(testViewObject, element);
|
let view = timelineView.view(testViewObject, element);
|
||||||
view.show(child, true);
|
view.show(child, true);
|
||||||
Vue.nextTick(done);
|
|
||||||
|
return Vue.nextTick();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('provides a view', () => {
|
it('provides a view', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user