构造函数中的Angular 单元测试

41zrol4v  于 2021-09-29  发布在  Java
关注(0)|答案(0)|浏览(280)

在构造函数中创建单元测试对我来说有点棘手。我被它困住了。在我的构造函数中,我有如下代码:

  1. constructor(
  2. private titleService: TitleService,
  3. private fb: FormBuilder,
  4. private router: Router,
  5. private authService: AuthService,
  6. private authProvider: ProviderService,
  7. private activatedroute: ActivatedRoute,
  8. private messageBoxService: MessageBoxService,
  9. private listProductService: ListProductService,
  10. private themeService: ThemeService,
  11. public messagingService: MessagingService,
  12. private statusService: StatusService,
  13. // private auth: AngularFireAuth,
  14. private fireDb: AngularFireDatabase,
  15. private httpClient: HttpClient,
  16. private gtmService: GtmService
  17. ) {
  18. if (history.state.isLogout) {
  19. this.authProvider.logout(+this.authService.getUserData.id).subscribe(data => {
  20. this.authService.logout();
  21. this.authProvider.signOutFirebase();
  22. this.cekUser = false;
  23. }, (_err)=> {
  24. this.cekUser = false;
  25. this.authService.logout();
  26. this.authProvider.signOutFirebase();
  27. });
  28. } else {
  29. this.statusService.getMe().subscribe((res) => {
  30. if (res) {
  31. this.router.navigate(['home']);
  32. }
  33. }, err => {
  34. this.cekUser = false;
  35. });
  36. }

如何为构造函数中的if-else条件创建最适合我的单元测试?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题