gpt4 book ai didi

Angular 2 测试 PrimeNG 确认对话框

转载 作者:行者123 更新时间:2023-11-28 20:50:52 30 4
gpt4 key购买 nike

我正在为以下代码编写 jasmine 单元测试:

this.confirmationService.confirm({
message: 'Are you sure that you want to delete?',
accept: () => {
//some code to test
}
});

我如何在对话框中假点击是,以测试里面的代码接受()函数?

最佳答案

在你的模板中:

<p-confirmDialog #confirmDialog header="Confirmation" icon="fa fa-question-circle" width="425"></p-confirmDialog>

在你的组件中:

@ViewChild('confirmDialog') confirmDialog: ConfirmDialog;

然后您就可以调用confirmDialog.accept()

关于Angular 2 测试 PrimeNG 确认对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47696534/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com