I have passed the api response value from one function to another function, But in JEST unit test case showing undefined, How to solve this error
angular code
this.content = this.commonSiteContent();
this.passingvalue(this.content.name);
jest.spyOn(srvice, 'commonSiteContent').mockReturnValue(mockContent);
component.ngOnInit();
expect(mockContent.getContentDetails).toHaveBeenCalledWith("sss");
expect(component.passvalue).toHaveBeenCalled()
I got the below error
TypeError: Cannot read property 'name' of undefined
27 |
28 |
29 | this.passvalue(this.content.name);
| ^
30 | }
31 | passvalue(name="" ){