title: Test Angular 2.0.0 component with HTTP request
body: <p>I have the following Angular 2.0.0 component:</p>
  
  <pre><code>import { Component, OnInit } from '@angular/core';
  import { Http } from '@angular/http';
  
  @Component({
    selector: 'app-book-list',
    templateUrl: './book-list.component.html',
    styleUrls: ['./book-list.component.css']
  })
  export class BookListComponent implements OnInit {
    books: any;
  
    constructor(private http: Http) { }
  
    ngOnInit() {
      this.http.get('/api/books.json')
        .subscribe(response =&gt; this.books = response.json());
    }
  
  }
  </code></pre>
  
  <p>How would I test the <code>ngOnInit()</code> function?</p>
  
  <p>I don't want to include the test I've tried so far because I suspect I'm way off the right track and I don't want to bias the answers.</p>