Fix appId not mandatory (#2038)

This commit is contained in:
Maurizio Vitale 2017-07-03 16:54:15 +01:00 committed by Eugenio Romano
parent 2e03ef3548
commit e33f6cf670
2 changed files with 14 additions and 13 deletions

View File

@ -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', () => {

View File

@ -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(