Skip to content
Snippets Groups Projects
Commit b1bf21d3 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-6002 OZG-6018 use constant

parent b74d6c93
Branches
Tags
No related merge requests found
...@@ -609,7 +609,7 @@ describe('VorgangDetailBescheidenResultComponent', () => { ...@@ -609,7 +609,7 @@ describe('VorgangDetailBescheidenResultComponent', () => {
expect(formService.getActiveStep).toHaveBeenCalled(); expect(formService.getActiveStep).toHaveBeenCalled();
}); });
it.each([1, 3])( it.each([1, VorgangDetailBescheidenResultComponent.BESCHEID_VERSENDEN_STEP])(
'should call bescheidService to clear attachment upload on step %s', 'should call bescheidService to clear attachment upload on step %s',
(step: number) => { (step: number) => {
formService.getActiveStep.mockReturnValue(of(step)); formService.getActiveStep.mockReturnValue(of(step));
...@@ -625,13 +625,16 @@ describe('VorgangDetailBescheidenResultComponent', () => { ...@@ -625,13 +625,16 @@ describe('VorgangDetailBescheidenResultComponent', () => {
component.resetSend = jest.fn(); component.resetSend = jest.fn();
}); });
it.each([1, 2])('should be called on step %s', (step: number) => { it.each([1, VorgangDetailBescheidenResultComponent.ADD_DOCUMENTS_STEP])(
'should be called on step %s',
(step: number) => {
formService.getActiveStep.mockReturnValue(of(step)); formService.getActiveStep.mockReturnValue(of(step));
component.getActiveStep().pipe(first()).subscribe(); component.getActiveStep().pipe(first()).subscribe();
expect(component.resetSend).toHaveBeenCalled(); expect(component.resetSend).toHaveBeenCalled();
}); },
);
it('should not be called on last step', () => { it('should not be called on last step', () => {
formService.getActiveStep.mockReturnValue(of(3)); formService.getActiveStep.mockReturnValue(of(3));
......
...@@ -28,7 +28,8 @@ type sendBescheid = ( ...@@ -28,7 +28,8 @@ type sendBescheid = (
templateUrl: './vorgang-detail-bescheiden-result.component.html', templateUrl: './vorgang-detail-bescheiden-result.component.html',
}) })
export class VorgangDetailBescheidenResultComponent implements OnInit { export class VorgangDetailBescheidenResultComponent implements OnInit {
private static readonly LAST_STEP: number = 3; static readonly ADD_DOCUMENTS_STEP: number = 2;
static readonly BESCHEID_VERSENDEN_STEP: number = 3;
@Output() closeDialog: EventEmitter<void> = new EventEmitter(); @Output() closeDialog: EventEmitter<void> = new EventEmitter();
...@@ -101,21 +102,22 @@ export class VorgangDetailBescheidenResultComponent implements OnInit { ...@@ -101,21 +102,22 @@ export class VorgangDetailBescheidenResultComponent implements OnInit {
} }
getActiveStep(): Observable<number> { getActiveStep(): Observable<number> {
return this.formService.getActiveStep().pipe( return this.formService
tap((step: number) => { .getActiveStep()
.pipe(tap((step: number) => this.handleStepChange(step)));
}
private handleStepChange(step: number): void {
if (this.isNotLast(step)) this.resetSend(); if (this.isNotLast(step)) this.resetSend();
if (this.shouldClearAttachmentInProgress(step)) if (this.shouldClearAttachmentInProgress(step)) this.bescheidService.clearAttachmentUpload();
this.bescheidService.clearAttachmentUpload();
}),
);
} }
private isNotLast(step: number): boolean { private isNotLast(step: number): boolean {
return step < VorgangDetailBescheidenResultComponent.LAST_STEP; return step < VorgangDetailBescheidenResultComponent.BESCHEID_VERSENDEN_STEP;
} }
private shouldClearAttachmentInProgress(step: number): boolean { private shouldClearAttachmentInProgress(step: number): boolean {
return step != 2; return step != VorgangDetailBescheidenResultComponent.ADD_DOCUMENTS_STEP;
} }
resetSend(): void { resetSend(): void {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment