diff --git a/src/plugins/condition/ConditionSpec.js b/src/plugins/condition/ConditionSpec.js index cc32914871..57d50abf9b 100644 --- a/src/plugins/condition/ConditionSpec.js +++ b/src/plugins/condition/ConditionSpec.js @@ -64,15 +64,17 @@ describe("The condition", function () { openmct.telemetry.getMetadata.and.returnValue(testTelemetryObject.telemetry.values); testConditionDefinition = { - trigger: TRIGGER.ANY, - criteria: [ - { - operation: 'equalTo', - input: false, - metaDataKey: 'value', - key: testTelemetryObject.identifier - } - ] + definition: { + trigger: 'any', + criteria: [ + { + operation: 'equalTo', + input: false, + metaDataKey: 'value', + key: testTelemetryObject.identifier + } + ] + } }; conditionObj = new Condition( @@ -85,7 +87,7 @@ describe("The condition", function () { }); it("generates criteria with an id", function () { - const testCriterion = testConditionDefinition.criteria[0]; + const testCriterion = testConditionDefinition.definition.criteria[0]; let criterion = conditionObj.generateCriterion(testCriterion); expect(criterion.id).toBeDefined(); expect(criterion.operation).toEqual(testCriterion.operation); @@ -101,15 +103,15 @@ describe("The condition", function () { it("initializes with criteria from the condition definition", function () { expect(conditionObj.criteria.length).toEqual(1); let criterion = conditionObj.criteria[0]; + console.log(criterion); expect(criterion instanceof TelemetryCriterion).toBeTrue(); - expect(criterion.operator).toEqual(testConditionDefinition.operator); - expect(criterion.input).toEqual(testConditionDefinition.input); - expect(criterion.metaDataKey).toEqual(testConditionDefinition.metaDataKey); - expect(criterion.key).toEqual(testConditionDefinition.key); + expect(criterion.operator).toEqual(testConditionDefinition.definition.criteria[0].operator); + expect(criterion.input).toEqual(testConditionDefinition.definition.criteria[0].input); + expect(criterion.metaDataKey).toEqual(testConditionDefinition.definition.criteria[0].metaDataKey); }); it("initializes with the trigger from the condition definition", function () { - expect(conditionObj.trigger).toEqual(testConditionDefinition.trigger); + expect(conditionObj.trigger).toEqual(testConditionDefinition.definition.trigger); }); it("destroys all criteria for a condition", function () { diff --git a/src/plugins/condition/criterion/TelemetryCriterion.js b/src/plugins/condition/criterion/TelemetryCriterion.js index 2d4dc72032..d833f25cfc 100644 --- a/src/plugins/condition/criterion/TelemetryCriterion.js +++ b/src/plugins/condition/criterion/TelemetryCriterion.js @@ -77,8 +77,9 @@ export default class TelemetryCriterion extends EventEmitter { let params = []; let result = false; params.push(data[this.metaDataKey]); - params.push(this.input[0]); - console.log(params); + if (this.input instanceof Array && this.input.length) { + params.push(this.input[0]); + } if (typeof comparator === 'function') { result = comparator(params); } diff --git a/src/plugins/condition/criterion/TelemetryCriterionSpec.js b/src/plugins/condition/criterion/TelemetryCriterionSpec.js index ef823ca45d..123fd600fb 100644 --- a/src/plugins/condition/criterion/TelemetryCriterionSpec.js +++ b/src/plugins/condition/criterion/TelemetryCriterionSpec.js @@ -94,17 +94,6 @@ describe("The telemetry criterion", function () { expect(telemetryCriterion.subscription).toBeDefined(); }); - it("normalizes telemetry data", function () { - let result = telemetryCriterion.normalizeData({ - key: 'some-key', - source: 'testSource', - testSource: 'Hello' - }); - expect(result).toEqual({ - 'some-key': 'Hello' - }) - }); - it("emits update event on new data from telemetry providers", function () { spyOn(telemetryCriterion, 'emitEvent').and.callThrough(); telemetryCriterion.handleSubscription({