I have this service that return all City from ws.
@Injectable()
export class CityService {
constructor(private http: Http, private router: Router,
private auth: AuthService) { }
public getAllCity(): Observable<City[]> {
let headers = new Headers();
headers.append('x-access-token', this.auth.getCurrentUser().token);
return this.http.get(Api.getUrl(Api.URLS.getAllCity), {
headers: headers
})
.map((response: Response) => {
let res = response.json();
if (res.StatusCode === 1) {
this.auth.logout();
} else {
return res.StatusDescription.map(city => {
return new City(city);
});
}
});
}
}
Now, I want to test this ws, I tried this code:
describe('Service: City', () => {
let component: CityService;
let fixture: ComponentFixture<CityService>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [],
providers: [CityService]
})
fixture = TestBed.get(CityService);
component = fixture.componentInstance;
});
});
Please, can you suggest me, how to test, how to show my city in ng test
? Also, please, this is my first work, can you suggest me any example, or tutorial like my code? Thanx
Aucun commentaire:
Enregistrer un commentaire