Refactoring and unit testing of Validator module (#3106)
* Added unit test for Validator, minimum viable version.
* Added test-console to package list
* Completed minimum viable unit test for Validator
* Added Validator unit test for explicit 'undefined'
// type of the field is incorrect and the field cannot be any
// type of the field is incorrect and the field cannot be any
console.log('%cInvalid type received for "'+option+'". Expected: '+Validator.print(Object.keys(refOptionObj))+'. Received ['+optionType+'] "'+options[option]+'"'+Validator.printLocation(path,option),printStyle);
'. Received ['+optionType+'] "'+options[option]+'"');
errorFound=true;
errorFound=true;
}
}
}
}
@ -166,19 +177,26 @@ class Validator {
letlocalSearchThreshold=8;
letlocalSearchThreshold=8;
letglobalSearchThreshold=4;
letglobalSearchThreshold=4;
letmsg;
if(localSearch.indexMatch!==undefined){
if(localSearch.indexMatch!==undefined){
console.log('%cUnknown option detected: "'+option+'" in '+Validator.printLocation(localSearch.path,option,'')+'Perhaps it was incomplete? Did you mean: "'+localSearch.indexMatch+'"?\n\n',printStyle);
msg=' in '+Validator.printLocation(localSearch.path,option,'')+
'Perhaps it was incomplete? Did you mean: "'+localSearch.indexMatch+'"?\n\n';
console.log('%cUnknown option detected: "'+option+'" in '+Validator.printLocation(localSearch.path,option,'')+'Perhaps it was misplaced? Matching option found at: '+Validator.printLocation(globalSearch.path,globalSearch.closestMatch,''),printStyle);
msg=' in '+Validator.printLocation(localSearch.path,option,'')+
'Perhaps it was misplaced? Matching option found at: '+
console.log('%cUnknown option detected: "'+option+'". Did you mean "'+localSearch.closestMatch+'"?'+Validator.printLocation(localSearch.path,option),printStyle);
msg='. Did you mean "'+localSearch.closestMatch+'"?'+
Validator.printLocation(localSearch.path,option);
}
}
else{
else{
console.log('%cUnknown option detected: "'+option+'". Did you mean one of these: '+Validator.print(Object.keys(options))+Validator.printLocation(path,option),printStyle);
msg='. Did you mean one of these: '+Validator.print(Object.keys(options))+