title: Angular 4 unit testing with jasmine /karma with http post mocking - how to fix
body: <p>I have a service I want to unit test in angular 4  typescript  jasmine.</p>
  
  <p>Now, the <code>http</code> is doing a <code>post</code> , and it returns an identity, however.. it is not sending anything. </p>
  
  <p>I want to just have good code coverage but i don't understand how to quite complete this mocking statement.</p>
  
  <p><strong>here is the method for http post in my service file</strong></p>
  
  <pre><code>addSession() {
          let headers = new Headers({ 'Content-Type': 'application/json' });
          let options = new RequestOptions({ headers: headers });
  
          return this.http.post(this.url, JSON.stringify({}), options)
              .map((response: Response) =&gt; response.json());
  
  }
  </code></pre>
  
  <p><strong>Then the SPEC FILE</strong> , which i don't get what to really test,  i suppose faking that i received a number back from the service http post,  the response should be something like  <code>000000014</code>    </p>
  
  <p><strong>Spec</strong></p>
  
  <pre><code>import { TrackerFormService } from './tracker-form.service'
  import { Observable } from 'rxjs/Observable'
  
  describe('TrackerFormService', () =&gt; {
  
      let trackerFormService: TrackerFormService,
          mockHttp;
  
      beforeEach(() =&gt; {
          mockHttp = jasmine.createSpyObj('mockHttp', ['get', 'post', 'put']
          )
          trackerFormService = new TrackerFormService(mockHttp);
      });
  
      describe('addSession', () =&gt; {
  
          it('add session ', () =&gt; {
                // how to test,  what to test?    
                // response , is a number?  how to mock/fake this?
  
          })
  
      })
  
  })
  </code></pre>