How to realize a jasmine test using http injection with a real backend?
I means that I would like to test my service using a real http connection
import { provide } from '@angular/core';
import{ClassCall} from 'xx.xx'
import {HTTP_PROVIDERS, XHRBackend, Http} from "@angular/http";
import {MockBackend} from "@angular/http/testing/mock_backend";
import {beforeEachProviders} from "@angular/core/testing/testing";
import {inject} from "@angular/core/testing/test_injector";
import {async} from "@angular/core/testing/async";
describe('HttpService Tests', () => {
beforeEachProviders(() => {
return [
HTTP_PROVIDERS,
Http,
ClassCall,
provide(ClassCall, {useClass: Http}),
];
})
it('should return response when subscribed to postRequest',
async(inject([ClassCall], (myCall: ClassCall) => {
myCall.Call("hey", "there")
.then((response)=>{
expect(response).toBe("anyResponse")
})
})));
});
I have not seen any topics about it....
Many thanks!!!!!
Aucun commentaire:
Enregistrer un commentaire