title: Is it possible to test a class' private method?
body: <p>In my Ionic 3 (Angular 4) app I have this code:</p>
  
  <pre><code>this.$observable.subscribe(success =&gt; {
    if (success) {
      this.toastCtrl.create({
        message: 'message,
        duration: 3000,
        position: 'middle'
      }).present();
    }
  });
  </code></pre>
  
  <p>What I want to test is whether <code>toastCtrl</code> is called is <code>$observable</code> emits <code>success = true</code>.</p>
  
  <p>This is what my test looks like:</p>
  
  <pre><code>it('when true, show toast', done =&gt; {
    fixture.whenStable().then(() =&gt; {
      component.$observable.subscribe(success =&gt; {
        if (success) {
          fixture.detectChanges();
          console.log(debugElement.query(By.css('.toast-message')));
          done();
          // expect(debugElement.query(By.css('.toast-message')).nativeElement).toBeDefined();
        }
      });
    });
  });
  </code></pre>
  
  <p>However it <strong>doesn't work</strong> as probably there is some delay in generating the toast (Note: I'm using Ionic Native but that element with that class is actually inserted in the DOM — even though just for 3 seconds and I tried even with 100s)</p>
  
  <p>Am I doing something wrong in <strong>testing async code</strong>?</p>
  
  <p>If not, <strong>how do I test that <code>this.toastCtrl</code> is called</strong> (apparently I cannot since it's a private property in component - as <strong>necessary to get it to work as it's injected in the constructor as ...</strong></p>
  
  <pre><code>constructor(private toastCtrl: ToastController)
  </code></pre>