【发布时间】:2021-05-15 05:53:49
【问题描述】:
要测试的功能
changeIva(idTax: number, index: number): void {
this.documentService.getTaxById(idTax).subscribe(tax => {
if (tax.codigo === 'ISE') this.openModal(index);
});
}
我走了多远
it('should test whether the tax is exempt or not', () => {
const taxMockSuccess = taxMock[0];
const idTax = 106;
const index = 1;
const modalOpenSpy = spyOn(component['modal'], 'open');
const documentServiceSpy = spyOn(documentService, 'getTaxById').and.returnValue(
of({ taxMockSuccess })
);
component.changeIva(idTax, index);
expect(documentServiceSpy).toBeCalledWith(idTax);
expect(modalOpenSpy).toBeCalled();
});
我需要帮助,我不知道如何在订阅中测试这个 IF
【问题讨论】:
标签: angular jestjs angular-observable angular-unit-test