I am starting to learn angular2.
Have a service with the following implementation:
@Injectable()
export class PostsService {
constructor(private http: Http) { }
getAllPosts() {
return this.http.get('/api/posts')
.map(res => res.json())
}
}
I am attempting to test this:
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpModule],
providers: [
PostsService,
{ provide: XHRBackend, useClass: MockBackend }
]
})
})
it('should be exposed', inject([PostsService], (service: PostsService) => {
expect(service).toBeTruthy()
}));
it('should use HTTP calls to obtain data results',
inject([PostsService],
fakeAsync((service: PostsService) => {
// test some mocked response data
// test connection
// whatever else needs to be tested
}
)));
I apologize, for such a simple request, but most of the guides I went through are outdated