【发布时间】:2018-10-19 07:44:43
【问题描述】:
我正在使用 BsModalRef 来显示模式并使用 content 属性发送数据。所以我们有一些这样的:
this.followerService.getFollowers(this.bsModalRef.content.channelId).subscribe((followers) => {
this.followerList = followers;
this.followerList.forEach((follower) => {
follower.avatarLink = this.setUserImage(follower.userId);
this.followerEmails.push(follower.email);
});
});
我们正在 bsModalRef (this.bsModalRef.content.channelId) 的内容中设置 channelId。它工作正常。现在我正在为此编写一个单元测试。问题是我无法模拟它。我尝试过覆盖、间谍等,但似乎没有任何效果。我正在使用link 中提到的方法。一种替代方法是使用 TestBed,但我不太了解它的用途。谁能帮我找到可以实现这一目标的任何方法?
【问题讨论】:
标签: unit-testing typescript karma-jasmine angular5 ngx-bootstrap