我正在开玩笑地为以下功能编写单元测试用例,并使用istanbul进行覆盖。这是我要为其编写单元测试用例的函数:
updatePaginationList (forwardOrBackward) {
let currentIndex = this.getCurrentIndexOfSelectedPage();
currentIndex = currentIndex + forwardOrBackward;
this.selIectedPageInPagination = this.PaginationElementList[currentIndex] ;
**this.updateCurrentVisiblePagination(forwardOrBackward,currentIndex);**
this.updatePaginationNextVisibility();
this.updatePaginationBackVisibility();
}
测试用例:
it('updateCurrentVisiblePaginationList should be called while updatePaginationList called', () => {
let spy = jest.spyOn(searchComponent, 'updateCurrentVisiblePagination');
searchComponent.updatePaginationList(1);
expect(spy).toHaveBeenCalled();
});
,但以下行未包括在本报告中:
this.updateCurrentVisiblePagination(forwardOrBackward,currentIndex);