js-lightning
Version:
Direct Javascript to Web interpreted server inspired by PHP
64 lines (45 loc) • 1.62 kB
JavaScript
;
//START OF moduleFunction() ============================================================
const moduleFunction = function(args) {
//this module is initialized with parameters spec'd in the main function module
const completeStepActual = ({verbose=false, logErrors=false, moduleName}) => (
methodName,
thisStepMessage,
thisStepResult,
thisStepEvalFunction
) => {
const thisStepPass = thisStepEvalFunction(thisStepResult);
if (logErrors && !thisStepPass) {
console.log(`FAIL TEST: ${thisStepMessage} in ...${moduleName}`);
}
if (verbose) {
console.log(`Result for: ${methodName} (${thisStepPass?'PASS':'FAIL'}):`);
console.dir(thisStepResult);
console.log('\n\n');
}
return passingTests && thisStepPass;
};
const completeStep = completeStepActual(args);
let passingTests = true;
let thisStepMessage;
let thisStepResult;
let thisStepEvalFunction;
let methodName;
//TESTS ============================================================
const testArray = [
'allocute',
'Hello'
];
//TEST ITEM ------------------------------------------------------
methodName='qtToString'
thisStepMessage = `${methodName} did not get the right string`;
thisStepResult = testArray[methodName]();
thisStepEvalFunction = item => item =='allocute, Hello';
passingTests =
completeStep(methodName, thisStepMessage, thisStepResult, thisStepEvalFunction) &&
passingTests;
return passingTests;
};
//END OF moduleFunction() ============================================================
module.exports = moduleFunction;
//module.exports = new moduleFunction();