构造函数中的Angular 单元测试

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

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

constructor(
    private titleService: TitleService,
    private fb: FormBuilder,
    private router: Router,
    private authService: AuthService,
    private authProvider: ProviderService,
    private activatedroute: ActivatedRoute,
    private messageBoxService: MessageBoxService,
    private listProductService: ListProductService,
    private themeService: ThemeService,
    public messagingService: MessagingService,
    private statusService: StatusService,
    // private auth: AngularFireAuth, 
    private fireDb: AngularFireDatabase,
    private httpClient: HttpClient,
    private gtmService: GtmService
  ) {
    if (history.state.isLogout) {
      this.authProvider.logout(+this.authService.getUserData.id).subscribe(data => {
        this.authService.logout();
        this.authProvider.signOutFirebase();
        this.cekUser = false;
      }, (_err)=> {
        this.cekUser = false;
        this.authService.logout();
        this.authProvider.signOutFirebase();
      });
    } else {
      this.statusService.getMe().subscribe((res) => {
        if (res) {
          this.router.navigate(['home']);
        }
      }, err => {
        this.cekUser = false;
      });

    }

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

暂无答案!

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

相关问题