【发布时间】:2021-04-10 00:52:19
【问题描述】:
我正在测试一个包含私有映射器方法的 Angular 服务,如下所示,我的目标是在 RxJS 映射中模拟该方法,因为它似乎没有经过覆盖测试。
这是我的 Jest 测试,但该方法似乎没有测试,也许我需要模拟私有方法?
test('should test the download file', () => {
const fakeurl = 'http://fakeurl';
service.downloadFile(fakeurl).subscribe((resp: IDownload) => {
expect(resp).toBe(mockDownloadedFile);
});
const req = httpMock.expectOne(request => request.url.includes(fakeurl), 'call api');
expect(req.request.method).toBe('GET');
req.flush(new Blob());
});
【问题讨论】:
标签: angular typescript jestjs