我正在学习Angular而且我想做测试,但是我被困了.我有一个功能:
ngOnInit(): void {
this.route.paramMap
.switchMap((params: ParamMap) =>
this.SomethingService.getSomething(params.get('id')))
.subscribe(something => {
this.something = something;
this.doSomethingElse();
});
}
Run Code Online (Sandbox Code Playgroud)
哪里
route: ActivatedRoute
Run Code Online (Sandbox Code Playgroud)
我想测试它,但我不知道如何模拟ActivatedRoute
我需要模拟NgbModal以角度进行一些单元测试,但我不知道如何做到这一点.这是我的功能:
openModal(deviceID: string, productID: string){
const modalRef = this.modalService.open(ProductModal)
modalRef.componentInstance.content = {
deviceId: deviceID,
productId: productID
}
modalRef.componentInstance.toEmit.subscribe(($e) => {
if ($e === true) this.reloadList();
});
}
Run Code Online (Sandbox Code Playgroud)
我应该做些什么?