mirror of
https://github.com/nasa/openmct.git
synced 2025-01-02 03:16:41 +00:00
Fixes unit tests
This commit is contained in:
parent
fcca8fa8d9
commit
0a634eb490
@ -62,6 +62,9 @@ describe("The condition", function () {
|
|||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
conditionManager.telemetryObjects = {
|
||||||
|
"test-object": testTelemetryObject
|
||||||
|
};
|
||||||
openmct.objects = jasmine.createSpyObj('objects', ['get', 'makeKeyString']);
|
openmct.objects = jasmine.createSpyObj('objects', ['get', 'makeKeyString']);
|
||||||
openmct.objects.get.and.returnValue(new Promise(function (resolve, reject) {
|
openmct.objects.get.and.returnValue(new Promise(function (resolve, reject) {
|
||||||
resolve(testTelemetryObject);
|
resolve(testTelemetryObject);
|
||||||
|
@ -24,7 +24,6 @@ import TelemetryCriterion from "./TelemetryCriterion";
|
|||||||
|
|
||||||
let openmct = {},
|
let openmct = {},
|
||||||
mockListener,
|
mockListener,
|
||||||
mockListener2,
|
|
||||||
testCriterionDefinition,
|
testCriterionDefinition,
|
||||||
testTelemetryObject,
|
testTelemetryObject,
|
||||||
telemetryCriterion;
|
telemetryCriterion;
|
||||||
@ -60,9 +59,6 @@ describe("The telemetry criterion", function () {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
openmct.objects = jasmine.createSpyObj('objects', ['get', 'makeKeyString']);
|
openmct.objects = jasmine.createSpyObj('objects', ['get', 'makeKeyString']);
|
||||||
openmct.objects.get.and.returnValue(new Promise(function (resolve, reject) {
|
|
||||||
resolve(testTelemetryObject);
|
|
||||||
}));
|
|
||||||
openmct.objects.makeKeyString.and.returnValue(testTelemetryObject.identifier.key);
|
openmct.objects.makeKeyString.and.returnValue(testTelemetryObject.identifier.key);
|
||||||
openmct.telemetry = jasmine.createSpyObj('telemetry', ['isTelemetryObject', "subscribe", "getMetadata"]);
|
openmct.telemetry = jasmine.createSpyObj('telemetry', ['isTelemetryObject', "subscribe", "getMetadata"]);
|
||||||
openmct.telemetry.isTelemetryObject.and.returnValue(true);
|
openmct.telemetry.isTelemetryObject.and.returnValue(true);
|
||||||
@ -80,13 +76,11 @@ describe("The telemetry criterion", function () {
|
|||||||
id: 'test-criterion-id',
|
id: 'test-criterion-id',
|
||||||
telemetry: openmct.objects.makeKeyString(testTelemetryObject.identifier),
|
telemetry: openmct.objects.makeKeyString(testTelemetryObject.identifier),
|
||||||
operation: 'lessThan',
|
operation: 'lessThan',
|
||||||
metadata: 'sin'
|
metadata: 'sin',
|
||||||
|
telemetryObject: testTelemetryObject
|
||||||
};
|
};
|
||||||
|
|
||||||
mockListener = jasmine.createSpy('listener');
|
mockListener = jasmine.createSpy('listener');
|
||||||
mockListener2 = jasmine.createSpy('updatedListener', (data) => {
|
|
||||||
console.log(data);
|
|
||||||
});
|
|
||||||
|
|
||||||
telemetryCriterion = new TelemetryCriterion(
|
telemetryCriterion = new TelemetryCriterion(
|
||||||
testCriterionDefinition,
|
testCriterionDefinition,
|
||||||
@ -94,18 +88,14 @@ describe("The telemetry criterion", function () {
|
|||||||
);
|
);
|
||||||
|
|
||||||
telemetryCriterion.on('criterionResultUpdated', mockListener);
|
telemetryCriterion.on('criterionResultUpdated', mockListener);
|
||||||
telemetryCriterion.on('criterionUpdated', mockListener2);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("initializes with a telemetry objectId as string", function () {
|
it("initializes with a telemetry objectId as string", function () {
|
||||||
telemetryCriterion.initialize(testTelemetryObject);
|
|
||||||
expect(telemetryCriterion.telemetryObjectIdAsString).toEqual(testTelemetryObject.identifier.key);
|
expect(telemetryCriterion.telemetryObjectIdAsString).toEqual(testTelemetryObject.identifier.key);
|
||||||
expect(mockListener2).toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("updates and emits event on new data from telemetry providers", function () {
|
it("updates and emits event on new data from telemetry providers", function () {
|
||||||
telemetryCriterion.initialize(testTelemetryObject);
|
|
||||||
spyOn(telemetryCriterion, 'emitEvent').and.callThrough();
|
spyOn(telemetryCriterion, 'emitEvent').and.callThrough();
|
||||||
telemetryCriterion.handleSubscription({
|
telemetryCriterion.handleSubscription({
|
||||||
value: 'Hello',
|
value: 'Hello',
|
||||||
|
Loading…
Reference in New Issue
Block a user