title: how to trigger a subscribe to an event emitter inside a function. Angular unit test
body: <p>I've been trying to test a function that contains a subscribe of an EventEmitter, the unit test is calling the subscribe but It has been impossible to test the code inside the subscribe, I mean, the <code>filter</code> and <code>getDocuments()</code> are not being tested even though the subscribe is being called.</p>
  
  <pre><code>  describe('trigger_data test', () =&gt; {
      it('not filter in storage', async(() =&gt; {
        component.filter = null;
        spyOn(component, 'getDocuments');
        spyOn(mockSharedService.trigger_data, 'subscribe').and.returnValue(of(true));
        component.triggerData();
        expect(mockSharedService.trigger_data.subscribe).toHaveBeenCalled();
        expect(component.filter).toEqual(1); //Error: Expected null to equal 1.
        expect(component.getDocuments).toHaveBeenCalled(); //Error: Expected spy getDocuments to have been called.
      }));
    });
  
  </code></pre>
  
  <p>This is the function</p>
  
  <pre><code>  triggerData() {
      this.sharedService.trigger_data.subscribe(() =&gt; {
        if (sessionStorage.getItem('filter_pp') !== null) {
          this.filter = Number(sessionStorage.getItem('filter_pp'));
        } else {
          this.filter = 1;
        }
        this.getDocuments();
      });
    }
  </code></pre>
  
  <p>When another component emits a boolean the subscribe trigger the code. </p>