diff --git a/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process.component.spec.ts b/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process.component.spec.ts index 3121e72ffb..238409cbdb 100644 --- a/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process.component.spec.ts +++ b/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process.component.spec.ts @@ -78,12 +78,20 @@ describe('ActivitiStartProcessInstance', () => { describe('process definitions list', () => { - it('should call service to fetch process definitions', () => { + it('should call service to fetch process definitions with appId', () => { let change = new SimpleChange(null, '123', true); component.ngOnChanges({'appId': change}); fixture.detectChanges(); - expect(getDefinitionsSpy).toHaveBeenCalled(); + expect(getDefinitionsSpy).toHaveBeenCalledWith('123'); + }); + + it('should call service to fetch process definitions without appId', () => { + let change = new SimpleChange(null, null, true); + component.ngOnChanges({'appId': change}); + fixture.detectChanges(); + + expect(getDefinitionsSpy).toHaveBeenCalledWith(null); }); it('should call service to fetch process definitions with appId when provided', () => { @@ -167,11 +175,6 @@ describe('ActivitiStartProcessInstance', () => { expect(getDefinitionsSpy).toHaveBeenCalledWith(null); }); - it('should not reload processes when changes do not include appId input', () => { - component.ngOnChanges({}); - expect(getDefinitionsSpy).not.toHaveBeenCalled(); - }); - }); describe('start process', () => { diff --git a/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process.component.ts b/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process.component.ts index ca729cb39e..d76fbb4407 100644 --- a/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process.component.ts +++ b/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process.component.ts @@ -65,14 +65,12 @@ export class ActivitiStartProcessInstance implements OnChanges { } ngOnChanges(changes: SimpleChanges) { - let appId = changes['appId']; - if (appId && (appId.currentValue || appId.currentValue === null)) { - this.load(appId.currentValue); - return; - } + let appIdChange = changes['appId']; + let appId = appIdChange ? appIdChange.currentValue : null; + this.load(appId); } - public load(appId: string) { + public load(appId?: string) { this.resetSelectedProcessDefinition(); this.resetErrorMessage(); this.activitiProcess.getProcessDefinitions(appId).subscribe(