title: How to unit test search functionality?
body: <p>First off, i'm just new to unit testing or testing in general so i'm still wrapping my head around some concepts. Already got the basic of unit testing and I'm also currently learning about rxjs marble testing, so currently i'm stuck on how to test searching w/c functions the same way with the code in the documentation.</p>
  <p>So Let's use the code from the tour of heroes in angular documentation</p>
  <pre><code>this.heroes$ = this.searchTerms.pipe(
    // wait 300ms after each keystroke before considering the term
    debounceTime(300),
  
    // ignore new term if same as previous term
    distinctUntilChanged(),
  
    // switch to new search observable each time the term changes
    switchMap((term: string) =&gt; this.heroService.searchHeroes(term)),
  );
  </code></pre>
  <p>Here's my current test looks like</p>
  <pre><code>const searchResults$ = (inputs$: Observable&lt;string&gt;) =&gt;
    inputs$.pipe(
      debounceTime(300),
      distinctUntilChanged(),
      switchMap((term: string) =&gt; fakeHeroService.searchHeroes(term))
    );
  
    it('should return the correct results', () =&gt; {
      scheduler.run(helpers =&gt; {
        const { cold, hot, expectObservable } = helpers;
  
        // these are the search terms typed by user, observable
        // emitted by this.searchTerms
        const inputMarbles = '^-a 300ms b-c 300ms';
  
        // each emitted response by each service call
        const outputMarbles = '-- 300ms a-- 300ms c';
  
        // verify that service is called N times
        // verify that it's passed with certain argument per run
  
  
        searchServiceSpy = spyOn(heroService, 'searchHeroes').and.returnValue(
          cold(outputMarbles)
        );
        const source$ = hot(inputMarbles);
  
        const output$ = source$.pipe(searchResults$);
  
        expectObservable(output$).toBe(outputMarbles);
  
        /* expect(fakeSearchService.getMatches).toHaveBeenCalledTimes(2); */
      });
    });
  </code></pre>
  <p>I just can't get it working.</p>