Hi Kiflemariam,

You can't really mock a method in the same class. Also, building your own 
subjects is not going to pan out in maintenance fees, returning new 
observables all over the place is going to end in major memory leakage.

export class AppService {
private currentValuesDB = new Subject<any>();
currentValues$ = this.currentValuesDB.asObservable();

setValues(): Observable<any> {
/** 
* ok, as you are not providing a value. I assume there is 
* something here that knows how to get that.
*/
this.currentValuesDB.next(/** whatever yo want to be in the subject. */)
return this.currentValues$.pipe(
map(oldValues => {
/** you might want to add some transformation here */
})
);
}
}

in this version, there is nothing to mock. you can grab the subject, and 
feed in whatever you need for testing. (even if it's a private!)

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/angular/657e9833-1644-4113-8455-5b527ec990c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to