diff --git a/alfa-client/libs/admin-settings/src/lib/organisationseinheit/organisationseinheit-container/organisationseinheit-form/organisationseinheit.formservice.spec.ts b/alfa-client/libs/admin-settings/src/lib/organisationseinheit/organisationseinheit-container/organisationseinheit-form/organisationseinheit.formservice.spec.ts index 6b4b53f7a409b37ef0aaf358cac49b30d7ee6056..1319b8d93554b29e92dfc3f46aee07a2b82f5eae 100644 --- a/alfa-client/libs/admin-settings/src/lib/organisationseinheit/organisationseinheit-container/organisationseinheit-form/organisationseinheit.formservice.spec.ts +++ b/alfa-client/libs/admin-settings/src/lib/organisationseinheit/organisationseinheit-container/organisationseinheit-form/organisationseinheit.formservice.spec.ts @@ -263,6 +263,14 @@ describe('OrganisationseinheitFormService', () => { describe('patch', () => { const organisationseinheit: Organisationseinheit = createOrganisationseinheit(); + it('should reset', () => { + formService.reset = jest.fn(); + + formService.patch(organisationseinheit); + + expect(formService.reset).toHaveBeenCalled(); + }); + it('should set source', () => { formService.patch(organisationseinheit); @@ -305,6 +313,14 @@ describe('OrganisationseinheitFormService', () => { }); describe('reset', () => { + it('should set source to null', () => { + formService.form.reset = jest.fn(); + + formService.reset(); + + expect(formService.source).toBeNull(); + }); + it('should call form reset', () => { formService.form.reset = jest.fn(); diff --git a/alfa-client/libs/admin-settings/src/lib/organisationseinheit/organisationseinheit-container/organisationseinheit-form/organisationseinheit.formservice.ts b/alfa-client/libs/admin-settings/src/lib/organisationseinheit/organisationseinheit-container/organisationseinheit-form/organisationseinheit.formservice.ts index 5d575985647d3bae7deb8ab6aade2a455b496539..ecad82623c8f1f5f192fd77ba5e96d381efedfa8 100644 --- a/alfa-client/libs/admin-settings/src/lib/organisationseinheit/organisationseinheit-container/organisationseinheit-form/organisationseinheit.formservice.ts +++ b/alfa-client/libs/admin-settings/src/lib/organisationseinheit/organisationseinheit-container/organisationseinheit-form/organisationseinheit.formservice.ts @@ -119,6 +119,7 @@ export class OrganisationseinheitFormservice { } public patch(organisationseinheit: Organisationseinheit): void { + this.reset(); this.source = organisationseinheit; this.form.patchValue({ [OrganisationseinheitFormservice.ORGANISATIONSEINHEIT_NAME_FIELD]: organisationseinheit.name, @@ -128,6 +129,7 @@ export class OrganisationseinheitFormservice { } public reset(): void { + this.source = null; this.form.reset(); this.form.markAsUntouched(); } diff --git a/alfa-client/libs/admin-settings/test/postfach/postfach.ts b/alfa-client/libs/admin-settings/test/postfach/postfach.ts index 5b7fb0003b346167c232422c8969062e8559dc1d..31fbf8b79bc0a23c2cbfae6a19d6f8ecd5d3c481 100644 --- a/alfa-client/libs/admin-settings/test/postfach/postfach.ts +++ b/alfa-client/libs/admin-settings/test/postfach/postfach.ts @@ -34,6 +34,6 @@ export function createPostfachResource(): PostfachResource { export function createSettingItemResource(): SettingItemResource { return toResource({ name: faker.random.word(), - settingsBody: {}, + settingBody: {}, }); }