I have this class service in Angular 6:

   export class AppService {

     setValues(): Observable<any> {

       const vm: any = this;
       return new Observable(observer => {
       vm.currentValues().subscribe(data => {
           // continue modifying data and reset it

        });
     });
   }

   public currentValues(): Observable<any> {


   return new Observable(observer => {
     observer.next('data goes here')

    });

  } 
 }





The currentValues() returns certain values that setValues() modifies using 
some formula. How can unittest setValues() by mocking currentValues() to 
return fixed values so that I can compare the output consistently? I have 
wanted to do the following but not sure how to plug it in:



export function mockCurrentValues () : Observable<any> { return of( 'data' ) }



-- 
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/4088e7e9-a451-49a0-b2f1-941dfa307d42%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to