-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(zaak-create.component): added component tests (#2380)
added tests Solves PZ-4875
- Loading branch information
Showing
2 changed files
with
165 additions
and
36 deletions.
There are no files selected for viewing
127 changes: 127 additions & 0 deletions
127
src/main/app/src/app/zaken/zaak-create/zaak-create.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Lifely | ||
* SPDX-License-Identifier: EUPL-1.2+ | ||
* | ||
*/ | ||
|
||
import { HttpClientTestingModule } from "@angular/common/http/testing"; | ||
import { TestBed } from "@angular/core/testing"; | ||
import { MatSidenavModule } from "@angular/material/sidenav"; | ||
import { provideAnimations } from "@angular/platform-browser/animations"; | ||
import { RouterModule } from "@angular/router"; | ||
import { TranslateModule } from "@ngx-translate/core"; | ||
import { of } from "rxjs"; | ||
import { CaseDefinition } from "../../admin/model/case-definition"; | ||
import { ReferentieTabelService } from "../../admin/referentie-tabel.service"; | ||
import { UtilService } from "../../core/service/util.service"; | ||
import { IdentityService } from "../../identity/identity.service"; | ||
import { KlantenService } from "../../klanten/klanten.service"; | ||
import { NavigationService } from "../../shared/navigation/navigation.service"; | ||
import { ZaakStatusmailOptie } from "../model/zaak-statusmail-optie"; | ||
import { Zaaktype } from "../model/zaaktype"; | ||
import { ZakenService } from "../zaken.service"; | ||
import { ZaakCreateComponent } from "./zaak-create.component"; | ||
|
||
describe(ZaakCreateComponent.name, () => { | ||
let component: ZaakCreateComponent; | ||
|
||
let identityService: IdentityService; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ZaakCreateComponent], | ||
providers: [ | ||
ZakenService, | ||
NavigationService, | ||
KlantenService, | ||
ReferentieTabelService, | ||
UtilService, | ||
IdentityService, | ||
provideAnimations(), | ||
], | ||
imports: [ | ||
RouterModule.forRoot([]), | ||
TranslateModule.forRoot(), | ||
HttpClientTestingModule, | ||
MatSidenavModule, | ||
], | ||
}).compileComponents(); | ||
|
||
const fixture = TestBed.createComponent(ZaakCreateComponent); | ||
component = fixture.componentInstance; | ||
|
||
identityService = TestBed.inject(IdentityService); | ||
jest | ||
.spyOn(identityService, "listGroups") | ||
.mockReturnValue(of([{ id: "test-group-id", naam: "test group" }])); | ||
jest | ||
.spyOn(identityService, "listUsersInGroup") | ||
.mockReturnValue(of([{ id: "test-user-id", naam: "test user" }])); | ||
}); | ||
|
||
describe( | ||
ZaakCreateComponent.prototype.getMedewerkerGroupFormField.name, | ||
() => { | ||
it("should set the medewerker group and name when exist", async () => { | ||
await component.ngOnInit(); | ||
|
||
const formField = await component.getMedewerkerGroupFormField( | ||
"test-group-id", | ||
"test-user-id", | ||
); | ||
|
||
expect(formField.medewerker.value).toEqual({ | ||
id: "test-user-id", | ||
naam: "test user", | ||
}); | ||
expect(formField.groep.value).toEqual({ | ||
id: "test-group-id", | ||
naam: "test group", | ||
}); | ||
}); | ||
}, | ||
); | ||
|
||
describe(ZaakCreateComponent.prototype.zaaktypeGeselecteerd.name, () => { | ||
it(`should call ${ZaakCreateComponent.prototype.getMedewerkerGroupFormField.name} with the default behandelaar and groep`, async () => { | ||
const getMedewerkerGroupFormField = jest.spyOn( | ||
component, | ||
"getMedewerkerGroupFormField", | ||
); | ||
await component.ngOnInit(); | ||
|
||
const zaakType = new Zaaktype(); | ||
zaakType.zaakafhandelparameters = { | ||
defaultBehandelaarId: "default-behandelaar", | ||
defaultGroepId: "default-group", | ||
einddatumGeplandWaarschuwing: 10, | ||
zaaktype: zaakType, | ||
afrondenMail: ZaakStatusmailOptie.BESCHIKBAAR_AAN, | ||
caseDefinition: new CaseDefinition(), | ||
creatiedatum: new Date().toJSON(), | ||
domein: "test", | ||
humanTaskParameters: [], | ||
intakeMail: ZaakStatusmailOptie.BESCHIKBAAR_AAN, | ||
mailtemplateKoppelingen: [], | ||
productaanvraagtype: "", | ||
uiterlijkeEinddatumAfdoeningWaarschuwing: 10, | ||
valide: true, | ||
userEventListenerParameters: [], | ||
zaakAfzenders: [], | ||
zaakbeeindigParameters: [], | ||
smartDocuments: {}, | ||
zaakNietOntvankelijkResultaattype: { | ||
id: "1", | ||
}, | ||
}; | ||
|
||
await component.zaaktypeGeselecteerd(zaakType); | ||
|
||
expect(getMedewerkerGroupFormField).toHaveBeenCalledTimes(2); // one for the init | ||
expect(getMedewerkerGroupFormField).toHaveBeenCalledWith( | ||
zaakType.zaakafhandelparameters.defaultGroepId, | ||
zaakType.zaakafhandelparameters.defaultBehandelaarId, | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters