Removed return null from methods

This commit is contained in:
Vito Albano 2016-09-20 17:59:39 +01:00
parent 8f6a9fb03b
commit 6f24b88465
2 changed files with 4 additions and 6 deletions

View File

@ -236,11 +236,11 @@ describe('WidgetVisibilityService', () => {
}); });
it('should return null if the variable does not exist', (done) => { it('should return undefined if the variable does not exist', (done) => {
service.getTaskProcessVariableModelsForTask(9999).subscribe( service.getTaskProcessVariableModelsForTask(9999).subscribe(
(res: TaskProcessVariableModel[]) => { (res: TaskProcessVariableModel[]) => {
let varValue = service.getValueFromVariable(formTest, 'TEST_MYSTERY_VAR', res); let varValue = service.getValueFromVariable(formTest, 'TEST_MYSTERY_VAR', res);
expect(varValue).toBeNull(); expect(varValue).toBeUndefined();
done(); done();
} }
); );

View File

@ -128,20 +128,18 @@ export class WidgetVisibilityService {
if ( form.json.variables) { if ( form.json.variables) {
let variableFromForm = form.json.variables.find(formVar => formVar.name === name); let variableFromForm = form.json.variables.find(formVar => formVar.name === name);
if ( variableFromForm ) { if ( variableFromForm ) {
return variableFromForm.value; return variableFromForm ? variableFromForm.value : variableFromForm;
} }
} }
return null;
} }
private getProcessVariableValue(name: string, processVarList: TaskProcessVariableModel[]) { private getProcessVariableValue(name: string, processVarList: TaskProcessVariableModel[]) {
if ( this.processVarList ) { if ( this.processVarList ) {
let variableFromProcess = this.processVarList.find(variable => variable.id === name); let variableFromProcess = this.processVarList.find(variable => variable.id === name);
if ( variableFromProcess ) { if ( variableFromProcess ) {
return variableFromProcess.value; return variableFromProcess ? variableFromProcess.value : variableFromProcess;
} }
} }
return null;
} }
private evaluateLogicalOperation(logicOp, previousValue, newValue): boolean { private evaluateLogicalOperation(logicOp, previousValue, newValue): boolean {