I would like to test get request related functionality. Request should be fired and values mapped to relevant object. Related code is:
it('Should have values set', () => {
const service: FetcherService = TestBed.get(FetcherService);
const technologyString = 'technology';
service.fetchNews(technologyString);
expect(service.fetchNewsResponse.category === technologyString);
});
Currently it however may not be relevant as relatated test fails with Karma and message is
TypeError: Cannot read property 'category' of undefined
What should I change in code to fix this issue?
edit:
Code related to service.fetchNews is:
public fetchNews(category: string) {
this.httpClient.get<News>('http://localhost:8080/news/' + this.country + '/' + category + '/')
.subscribe(data => this.fetchNewsResponse = data );
}