问题描述
我正在尝试测试几个使用 await 的函数,但覆盖范围并未涵盖使用 Sinon 的所有函数:
这是我正在测试的功能:
public async GenerarSolicitud(
selectedSearched: ISearchedBIT,selectedDocs: Array<IDocumentoBIT>,emailUser: string,) {
try {
const requestEntity = this.buildrequestEntity(
selectedSearched,selectedDocs,);
const request = await this.pnp.insertItem(
ListNamePOARequest,requestEntity
);
const files = await this.descargararchivosSolicitudPOA(selectedDocs);
const attachment = await this.pnp.addAttachmentToItem(
ListNamePOARequest,request.ID,"ResumenPOA.zip",files
);
if (emailUser) {
this.sendNewPOANotification(request.ID,[emailUser],attachment);
}
return request;
} catch (err) {
throw new Error(err);
}
}
这是测试:
test(`dado => un llamado GenerarSolicitud
cuando => idInit existe
entonces => GenerarSolicitud esta definido`,async () => {
buildrequestEntity.returnValues.push(Promise.resolve({ ID: 1 }))
insertItem.returnValues.push(Promise.resolve({ ID: 1 }))
descargararchivosSolicitudPOA.returnValues.push(Promise.resolve({ file: {} }))
addAttachmentToItem.returnValues.push(Promise.resolve({}))
sendNewPOANotification.resolves([])
utilsPOA2.GenerarSolicitud({
Grupo: "",Tematica: "",Especialidad: ""
},[{
Id: "2",ID: "",DescripcionDocumentoBIT: "des"
}],user.email).then(res => {
expect(res).tobedefined()
}).catch()
})
这是覆盖范围:
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)