mirror of
https://github.com/nasa/openmct.git
synced 2025-01-21 12:05:12 +00:00
Removes use of createOpenMCT and uses mock object for openmct instead.
This commit is contained in:
parent
36055b7c04
commit
7cf6dc386f
@ -24,15 +24,15 @@ import * as EventEmitter from 'eventemitter3';
|
||||
|
||||
export default class TelemetryCriterion extends EventEmitter {
|
||||
|
||||
constructor(telemetryDomainObject, openmct) {
|
||||
constructor(telemetryDomainObjectKey, openmct) {
|
||||
super();
|
||||
|
||||
this.telemetryObject = telemetryDomainObject;
|
||||
this.openmct = openmct;
|
||||
this.telemetryObject = this.openmct.objects.get(this.openmct.objects.makeKeyString(telemetryDomainObjectKey));
|
||||
this.telemetryAPI = this.openmct.telemetry;
|
||||
this.subscription = null;
|
||||
this.telemetryObjectIdAsString = null;
|
||||
this.telemetryMetadata = null;
|
||||
this.telemetryObjectIdAsString = null;
|
||||
if (this.telemetryAPI.isTelemetryObject(this.telemetryObject)) {
|
||||
this.telemetryObjectIdAsString = this.openmct.objects.makeKeyString(this.telemetryObject.identifier);
|
||||
}
|
||||
@ -73,7 +73,9 @@ export default class TelemetryCriterion extends EventEmitter {
|
||||
*/
|
||||
unsubscribe() {
|
||||
//unsubscribe from telemetry source
|
||||
this.subscription();
|
||||
if (typeof this.subscription === 'function') {
|
||||
this.subscription();
|
||||
}
|
||||
delete this.subscription;
|
||||
this.emit('criterion::Remove', this.telemetryObjectIdAsString);
|
||||
delete this.telemetryObjectIdAsString;
|
||||
|
@ -21,9 +21,8 @@
|
||||
*****************************************************************************/
|
||||
|
||||
import TelemetryCriterion from "./TelemetryCriterion";
|
||||
import { createOpenMct } from "../../../testTools";
|
||||
|
||||
let openmct = createOpenMct(),
|
||||
let openmct = {},
|
||||
mockListener,
|
||||
testTelemetryObject,
|
||||
telemetryCriterion;
|
||||
@ -31,7 +30,6 @@ let openmct = createOpenMct(),
|
||||
describe("The telemetry criterion", function () {
|
||||
|
||||
beforeEach (() => {
|
||||
mockListener = jasmine.createSpy('listener');
|
||||
testTelemetryObject = {
|
||||
identifier:{ namespace: "", key: "test-object"},
|
||||
type: "test-object",
|
||||
@ -52,9 +50,17 @@ describe("The telemetry criterion", function () {
|
||||
}]
|
||||
}
|
||||
};
|
||||
openmct.objects = jasmine.createSpyObj('objects', ['get', 'makeKeyString', ]);
|
||||
openmct.objects.get.and.returnValue(testTelemetryObject);
|
||||
openmct.objects.makeKeyString.and.returnValue(testTelemetryObject.identifier.key);
|
||||
openmct.telemetry = jasmine.createSpyObj('telemetry', ['isTelemetryObject', "subscribe"]);
|
||||
openmct.telemetry.isTelemetryObject.and.returnValue(true);
|
||||
openmct.telemetry.subscribe.and.returnValue(function () {});
|
||||
|
||||
mockListener = jasmine.createSpy('listener');
|
||||
|
||||
telemetryCriterion = new TelemetryCriterion(
|
||||
testTelemetryObject,
|
||||
testTelemetryObject.identifier,
|
||||
openmct
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user