.ts file:
ngOnInit(): void {
if (
this.activatedRoute.snapshot.queryParamMap.has('esign') &&
this.activatedRoute.snapshot.queryParamMap.has('registration')
) {
this.eSignAndRegistration = true;
}
.spec.ts file:
let esign_registration = false;
const mockActivatedRoute = {
snapshot: {
queryParamMap: {
has: (response) => {
if (response == 'esign' && response == 'registration') {
return esign_registration;
}
test:
fit("should show the 1st mat-card if the param is 'esign®istration'", () => {
esign_registration = true;
fixture.detectChanges();
component.ngOnInit();
fixture.detectChanges();
const compiled = fixture.nativeElement;
expect(component.eSignAndRegistration).toBeTruthy();
});
The error keeps coming as "Expected undefined to be truthy." How does the 'has' if statement need to be written to get the unit test to work? I have tried
if (response == 'esign' && 'registration')
and
if (response == 'esign®istration')
and whole variety of other methods, but they all kept giving the same error.
Aucun commentaire:
Enregistrer un commentaire