I have a service similar to the below code:
allCustomerList = []
getCustomerList() {
return new Observable((observer) => {
const local = localStorage.getItem('customerList');
this.allCustomerList = local ? JSON.parse(local) : [];
observer.next(this.allCustomerList);
})}
getcustomerByEmail(email: string) { return new Observable((observer) => {
const customer = this.findCustomer(email) observer.next(customer); })
}
findCustomer(email: string) {
return this.allCustomerList.find(x => x.Email === email);`
}
I want to write unit test for this but I cannot. Can you help me to fix it?