So I'm still very new to rxjs.
Currently using tape js for unit tests in my code base. I've looked into marble diagram testing, but it's really not clicking for me.
My question : How to unit test a search call that makes use of rxjs observable? I'm interested in asserting that the _handleSearchResults function is called with the observable completes. Similarly how to test if the observable fails, that the _handleSearchError is called.
this.searchSubject is a rx subject
searchChanged(query) {
this.searchSubject.next(query);
}
Search subject is defined with the switchmap which is really what I want to unit test when calling searchChanged.
this.searchSubject.switchMap(searchQuery => {
return Rx.Observable.fromPromise(this._queryAutoComplete(searchQuery));
})
.subscribe(this._handleSearchResults.bind(this), this._handleSearchError.bind(this));