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' ) }