mirror of
https://github.com/nasa/openmct.git
synced 2025-01-18 10:46:42 +00:00
add isDefined condition in condition Evaluator which fixes Issue 1860
Add appropriate tests Fix for isUndefined not working as well
This commit is contained in:
parent
3f1b7e0a87
commit
aa8fa9168a
@ -206,6 +206,17 @@ define([], function () {
|
||||
getDescription: function () {
|
||||
return ' is undefined';
|
||||
}
|
||||
},
|
||||
isDefined: {
|
||||
operation: function (input) {
|
||||
return typeof input[0] !== 'undefined';
|
||||
},
|
||||
text: 'is defined',
|
||||
appliesTo: ['string', 'number'],
|
||||
inputCount: 0,
|
||||
getDescription: function () {
|
||||
return ' is defined';
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -304,9 +315,12 @@ define([], function () {
|
||||
op = this.operations[operation] && this.operations[operation].operation;
|
||||
input = telemetryValue && telemetryValue.concat(values);
|
||||
validator = op && this.inputValidators[this.operations[operation].appliesTo[0]];
|
||||
|
||||
if (op && input && validator) {
|
||||
return validator(input) && op(input);
|
||||
if (this.operations[operation].appliesTo.length === 2) {
|
||||
return (this.validateNumberInput(input) || this.validateStringInput(input)) && op(input);
|
||||
} else {
|
||||
return validator(input) && op(input);
|
||||
}
|
||||
} else {
|
||||
throw new Error('Malformed condition');
|
||||
}
|
||||
|
@ -325,6 +325,10 @@ define(['../src/ConditionEvaluator'], function (ConditionEvaluator) {
|
||||
testOperation = testEvaluator.operations.isUndefined.operation;
|
||||
expect(testOperation([1])).toEqual(false);
|
||||
expect(testOperation([])).toEqual(true);
|
||||
//isDefined
|
||||
testOperation = testEvaluator.operations.isDefined.operation;
|
||||
expect(testOperation([1])).toEqual(true);
|
||||
expect(testOperation([])).toEqual(false);
|
||||
});
|
||||
|
||||
it('can produce a description for all supported operations', function () {
|
||||
|
Loading…
Reference in New Issue
Block a user