From 4e6be6acf3154629b96017a049eac8b3c6fe8ce6 Mon Sep 17 00:00:00 2001 From: gspikehalo <2318002579@qq.com> Date: Wed, 15 Jan 2025 20:13:07 -0800 Subject: [PATCH] update test file --- .../google-login.component.spec.ts | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/core/gui/src/app/dashboard/component/user/google-login/google-login.component.spec.ts b/core/gui/src/app/dashboard/component/user/google-login/google-login.component.spec.ts index e4799e44af..884e666251 100644 --- a/core/gui/src/app/dashboard/component/user/google-login/google-login.component.spec.ts +++ b/core/gui/src/app/dashboard/component/user/google-login/google-login.component.spec.ts @@ -1,20 +1,36 @@ import { ComponentFixture, TestBed } from "@angular/core/testing"; import { GoogleLoginComponent } from "./google-login.component"; -import { NO_ERRORS_SCHEMA } from "@angular/core"; +import { HttpClientTestingModule } from "@angular/common/http/testing"; +import { RouterTestingModule } from "@angular/router/testing"; +import { UserService } from "../../../../common/service/user/user.service"; +import { SocialAuthService } from "@abacritt/angularx-social-login"; +import { of } from "rxjs"; describe("GoogleLoginComponent", () => { let component: GoogleLoginComponent; let fixture: ComponentFixture; + let userService: jasmine.SpyObj; + let socialAuthService: jasmine.SpyObj; beforeEach(async () => { + const userServiceSpy = jasmine.createSpyObj("UserService", ["googleLogin"]); + const socialAuthServiceSpy = jasmine.createSpyObj("SocialAuthService", [], { + authState: of({ idToken: "mock-id-token" }), + }); + await TestBed.configureTestingModule({ + imports: [HttpClientTestingModule, RouterTestingModule], declarations: [GoogleLoginComponent], - schemas: [NO_ERRORS_SCHEMA], + providers: [ + { provide: UserService, useValue: userServiceSpy }, + { provide: SocialAuthService, useValue: socialAuthServiceSpy }, + ], }).compileComponents(); fixture = TestBed.createComponent(GoogleLoginComponent); component = fixture.componentInstance; - fixture.detectChanges(); + userService = TestBed.inject(UserService) as jasmine.SpyObj; + socialAuthService = TestBed.inject(SocialAuthService) as jasmine.SpyObj; }); it("should create the component", () => {