fit('should call the expected URL', () => {
TestBed.runInInjectionContext(() => {
const resource = service.fetchSettings(); //httpResourceRef
resource.reload();
const req = httpMock.expectOne(`${environment.baseUrls.api.wellcomm}/1.0/cluster/getPendingSettings`); //HttpTestingController
expect(req.request.method).toBe('GET');
req.flush({});
});
});
我希望这会触发请求方法,以使测试通过。但是,不是。
我知道它与组件如何读取它有关,但是我该如何模仿呢?每次使用此信息时,我都必须构建一个读取和呈现数据的组件吗?
您应该使用
HttpTestingController
,因为已经进行了测试。
HttpClient