Skip to content
Snippets Groups Projects
Commit d221dcc6 authored by Jan Zickermann's avatar Jan Zickermann
Browse files

Merge pull request 'OZG-4995-FixUpdate' (#500) from OZG-4995-FixUpdate into master

parents 3b80d877 c09ae932
Branches
Tags
No related merge requests found
...@@ -263,6 +263,14 @@ describe('OrganisationseinheitFormService', () => { ...@@ -263,6 +263,14 @@ describe('OrganisationseinheitFormService', () => {
describe('patch', () => { describe('patch', () => {
const organisationseinheit: Organisationseinheit = createOrganisationseinheit(); const organisationseinheit: Organisationseinheit = createOrganisationseinheit();
it('should reset', () => {
formService.reset = jest.fn();
formService.patch(organisationseinheit);
expect(formService.reset).toHaveBeenCalled();
});
it('should set source', () => { it('should set source', () => {
formService.patch(organisationseinheit); formService.patch(organisationseinheit);
...@@ -305,6 +313,14 @@ describe('OrganisationseinheitFormService', () => { ...@@ -305,6 +313,14 @@ describe('OrganisationseinheitFormService', () => {
}); });
describe('reset', () => { describe('reset', () => {
it('should set source to null', () => {
formService.form.reset = jest.fn();
formService.reset();
expect(formService.source).toBeNull();
});
it('should call form reset', () => { it('should call form reset', () => {
formService.form.reset = jest.fn(); formService.form.reset = jest.fn();
......
...@@ -119,6 +119,7 @@ export class OrganisationseinheitFormservice { ...@@ -119,6 +119,7 @@ export class OrganisationseinheitFormservice {
} }
public patch(organisationseinheit: Organisationseinheit): void { public patch(organisationseinheit: Organisationseinheit): void {
this.reset();
this.source = organisationseinheit; this.source = organisationseinheit;
this.form.patchValue({ this.form.patchValue({
[OrganisationseinheitFormservice.ORGANISATIONSEINHEIT_NAME_FIELD]: organisationseinheit.name, [OrganisationseinheitFormservice.ORGANISATIONSEINHEIT_NAME_FIELD]: organisationseinheit.name,
...@@ -128,6 +129,7 @@ export class OrganisationseinheitFormservice { ...@@ -128,6 +129,7 @@ export class OrganisationseinheitFormservice {
} }
public reset(): void { public reset(): void {
this.source = null;
this.form.reset(); this.form.reset();
this.form.markAsUntouched(); this.form.markAsUntouched();
} }
......
...@@ -34,6 +34,6 @@ export function createPostfachResource(): PostfachResource { ...@@ -34,6 +34,6 @@ export function createPostfachResource(): PostfachResource {
export function createSettingItemResource(): SettingItemResource { export function createSettingItemResource(): SettingItemResource {
return toResource({ return toResource({
name: faker.random.word(), name: faker.random.word(),
settingsBody: {}, settingBody: {},
}); });
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment