有没有办法使用角度的“测试库”框架测试私有方法或声明?
这是我的代码:
priave name = "somename"
private setLang(url: string, fetch: boolean) {
switch (url) {
case '/SSB/mngt':
this.SSB.Id = 'newSSb';
this.pageId = 'ManageEvent';
break;
case '/SSB/mngt/add':
this.SSB.Id = 'newSSb';
this.pageId = 'ManageEventAdd';
break;
case '/SSB/mngt/view':
this.SSB.Id = 'newSSb';
this.pageId = 'ManageEventView';
break;
case '/SSB/mngt/approve':
this.SSB.Id = 'newSSb';
this.pageId = 'ManageEventApprove';
break;
default:
this.SSB.Id = 'setupConfig';
this.pageId = 'ViewProgMgmt';
break;
}
this.data = [];
this.data.push(this.selectedLang);
this.data.push(this.SSB.Id);
this.data.push(this.pageId);
this.data.push(fetch);
this.langId.emit(this.data);
}
私有name
声明和setLang
方法都不可用,规范文件。什么是正确的处理方式。看来,除非我为我的两个私有声明编写测试用例,否则我无法达到 100% 的覆盖率。