I'm working with Angular 13. I am trying to test a method assigned to variable that looks like this:
constructor(route: ActivatedRoute) {}
compFunction(id: number) {
if (id) {
let result = this.returnFunction();
}
}
returnFunction() {
return this.route.snapshot.paramMap.get('id')
}
First I have tried this:
it("should open foo page", inject((omitted)) => {
component.compFunction('id')
const data = component.returnFunction(); // not working this line
data.toLowerCase();
}));
But I am getting the following error
cannot read properties of undefined (reading: 'toLowerCase')
Secondly I tried to mock the function and assigned it but it didn't work.