diff --git a/alfa-client/libs/design-component/src/lib/form/formcontrol-editor.abstract.component.spec.ts b/alfa-client/libs/design-component/src/lib/form/formcontrol-editor.abstract.component.spec.ts index c12275820fa45999a9674b1cb5d811c81dd94e22..d27faa36322f20ca92d14d46628f409a1d248745 100644 --- a/alfa-client/libs/design-component/src/lib/form/formcontrol-editor.abstract.component.spec.ts +++ b/alfa-client/libs/design-component/src/lib/form/formcontrol-editor.abstract.component.spec.ts @@ -21,29 +21,29 @@ describe('FormControlEditorAbstractComponent', () => { fixture.detectChanges(); }); - describe('ng on init', () => { - it('should set valueChange subscription', () => { + describe('ngOnInit', () => { + it('should set subscription', () => { component.ngOnInit(); - expect(component._changesSubscr).toBeDefined(); + expect(component._changesSubscription).toBeDefined(); }); - it('should call field control on change handler when fieldControl value changes ', () => { - component._fieldControlOnChangeHandler = jest.fn(); + it('should handle field control value changes ', () => { + component.handleFieldControlValueChange = jest.fn(); component.ngOnInit(); component.fieldControl.setValue('testValue'); - expect(component._fieldControlOnChangeHandler).toHaveBeenCalledWith('testValue'); + expect(component.handleFieldControlValueChange).toHaveBeenCalledWith('testValue'); }); - it('should set statusChange subscription', () => { + it('should set subscription', () => { component.ngOnInit(); - expect(component._statusSubscr).toBeDefined(); + expect(component._statusSubscription).toBeDefined(); }); - it('should call setErrors on statusChange', () => { + it('should set errors on statusChange', () => { component.setErrors = jest.fn(); component.ngOnInit(); @@ -54,7 +54,7 @@ describe('FormControlEditorAbstractComponent', () => { }); describe('writeValue', () => { - it('should set value to fieldControl', () => { + it('should set fieldControl value', () => { const value = 'testValue'; component.writeValue(value); @@ -72,7 +72,7 @@ describe('FormControlEditorAbstractComponent', () => { expect(component.fieldControl.errors).toEqual(errors); }); - it('should call update invalid params', () => { + it('should update invalid params', () => { component._updateInvalidParams = jest.fn(); component.setErrors(); @@ -81,7 +81,7 @@ describe('FormControlEditorAbstractComponent', () => { }); }); - describe('remove errors', () => { + describe('removeErrors', () => { it('should remove fieldControl errors', () => { component.fieldControl.setErrors({ fehler: 'this is an validation error' }); @@ -90,7 +90,7 @@ describe('FormControlEditorAbstractComponent', () => { expect(component.fieldControl.errors).toBeNull(); }); - it('should call update invalid params', () => { + it('should update invalid params', () => { component._updateInvalidParams = jest.fn(); component._removeErrors(); diff --git a/alfa-client/libs/design-component/src/lib/form/formcontrol-editor.abstract.component.ts b/alfa-client/libs/design-component/src/lib/form/formcontrol-editor.abstract.component.ts index 17f8e719998fe87a809421fe13d2680361ed3d07..02760de1007d248b2b3bb2107b30501d54a6263c 100644 --- a/alfa-client/libs/design-component/src/lib/form/formcontrol-editor.abstract.component.ts +++ b/alfa-client/libs/design-component/src/lib/form/formcontrol-editor.abstract.component.ts @@ -35,8 +35,8 @@ export abstract class FormControlEditorAbstractComponent implements ControlValue public onTouched = () => undefined; public invalidParams: InvalidParam[] = []; - _changesSubscr: Subscription; - _statusSubscr: Subscription; + _changesSubscription: Subscription; + _statusSubscription: Subscription; disabled: boolean = false; @@ -45,16 +45,18 @@ export abstract class FormControlEditorAbstractComponent implements ControlValue } ngOnInit(): void { - this._changesSubscr = this.fieldControl.valueChanges.subscribe((value: unknown) => this._fieldControlOnChangeHandler(value)); + this._changesSubscription = this.fieldControl.valueChanges.subscribe((value: unknown) => + this.handleFieldControlValueChange(value), + ); if (this.control) { - this._statusSubscr = this.control.statusChanges.subscribe(() => { + this._statusSubscription = this.control.statusChanges.subscribe(() => { this.setErrors(); }); } } - _fieldControlOnChangeHandler(value: unknown): void { + handleFieldControlValueChange(value: unknown): void { this.onChange(value); this._removeErrors(); } @@ -80,8 +82,8 @@ export abstract class FormControlEditorAbstractComponent implements ControlValue } ngOnDestroy(): void { - if (this._changesSubscr) this._changesSubscr.unsubscribe(); - if (this._statusSubscr) this._statusSubscr.unsubscribe(); + if (this._changesSubscription) this._changesSubscription.unsubscribe(); + if (this._statusSubscription) this._statusSubscription.unsubscribe(); } setErrors(): void {