为事件发射器编写测试用例。modelopen()为方法编写测试用例
父ts文件author-article-carousel.component.ts
public edit(row) {
console.log(row);
this.activeArticleService.getArticleDetail(row.id).subscribe((res: any) => {
this.modalOpen(res);
});
}
public modalOpen(value) {
let config = {};
config = {
disableClose: true,
maxWidth: '1050px',
data: { value: value, user: 'author' }
};
if (this.dialogRef == null) {
this.dialogRef = this.dialog.open(ArticleModalComponent, config);
}
this.dialogRef.afterClosed().subscribe(result => {
console.log(`Dialog closed: ${result}`);
this.dialogRef = null;
});
this.dialogRef.componentInstance.downloadreport.subscribe(response => {
if (response) {
this.activeArticleService.downloadReport(response).subscribe((response: HttpResponse<Blob>) => {
this.activeArticleService.download(response, 'report.pdf');
});
}
});
}
Run Code Online (Sandbox Code Playgroud)
父 HTML 文件author-article-carousel.component.html
<prism-article-carousel
(clickOnTitle)="edit($event)"
></prism-article-carousel>
Run Code Online (Sandbox Code Playgroud)
子 …