import { TestBed , inject } from '@angular/core/testing' ; import { Http , BaseRequestOptions } from '@angular/http' ; import { MockBackend } from '@angular/http/testing' ; import { PostsService } from './posts.service' ; describe ( 'PostsService' , ( ) => { beforeEach ( ( ) => { TestBed . configureTestingModule ( { providers : [ MockBackend , BaseRequestOptions , { provide : Http , useFactory : ( backendInstance , defaultOptions ) => { return new Http ( backendInstance , defaultOptions ) ; } , deps : [ MockBackend , BaseRequestOptions ] } , PostsService ] } ) ; } ) ; it ( 'should ...' , inject ( [ PostsService ] , ( service ) => { expect ( service ) . toBeTruthy ( ) ; } ) ) ; } ) ;