How to get coverage for array with .find method in angular. I'm getting trouble in the below piece of code.
sample.component.ts
public permissions = [{id: 0, value: 'fruit' }, {id: 1, value: 'vegetable'}];
this.filteredList = this.permissions.slice();
public isFiltered(permission) {
return this.filteredList.find(item => item.id === permission.id);
}
sample.spec.ts
it('should call myMethod ', () => {
expect(component.isFiltered(1)).toEqual(true);
});
I'm getting the following error ,
TypeError: Cannot read property 'find' of undefined
Any help would be appreciated