Mct4041 - Reimplement in-memory search (#4527)

Re-implements the in-memory search index sans Angular

Co-authored-by: Andrew Henry <akhenry@gmail.com>
Co-authored-by: John Hill <john.c.hill@nasa.gov>
Co-authored-by: John Hill <jchill2.spam@gmail.com>
This commit is contained in:
Scott Bell
2021-12-16 01:13:41 +01:00
committed by GitHub
parent e18c7562ae
commit 1f588a2a6e
24 changed files with 627 additions and 2409 deletions

View File

@@ -1,4 +1,5 @@
import ObjectAPI from './ObjectAPI.js';
import { createOpenMct, resetApplicationState } from '../../utils/testing';
describe("The Object API", () => {
let objectAPI;
@@ -9,10 +10,11 @@ describe("The Object API", () => {
const TEST_NAMESPACE = "test-namespace";
const FIFTEEN_MINUTES = 15 * 60 * 1000;
beforeEach(() => {
beforeEach((done) => {
typeRegistry = jasmine.createSpyObj('typeRegistry', [
'get'
]);
openmct = createOpenMct();
openmct.$injector = jasmine.createSpyObj('$injector', ['get']);
mockIdentifierService = jasmine.createSpyObj(
'identifierService',
@@ -25,7 +27,7 @@ describe("The Object API", () => {
});
openmct.$injector.get.and.returnValue(mockIdentifierService);
objectAPI = new ObjectAPI(typeRegistry, openmct);
objectAPI = openmct.objects;
openmct.editor = {};
openmct.editor.isEditing = () => false;
@@ -38,15 +40,29 @@ describe("The Object API", () => {
name: "test object",
type: "test-type"
};
openmct.on('start', () => {
done();
});
openmct.startHeadless();
});
afterEach(async () => {
await resetApplicationState(openmct);
});
describe("The save function", () => {
it("Rejects if no provider available", () => {
it("Rejects if no provider available", async () => {
let rejected = false;
objectAPI.providers = {};
objectAPI.fallbackProvider = null;
return objectAPI.save(mockDomainObject)
.catch(() => rejected = true)
.then(() => expect(rejected).toBe(true));
try {
await objectAPI.save(mockDomainObject);
} catch (error) {
rejected = true;
}
expect(rejected).toBe(true);
});
describe("when a provider is available", () => {
let mockProvider;