diff --git a/ui/src/app/home/home.component.spec.ts b/ui/src/app/home/home.component.spec.ts index 42d2c88ab..cc6db2491 100644 --- a/ui/src/app/home/home.component.spec.ts +++ b/ui/src/app/home/home.component.spec.ts @@ -1,32 +1,25 @@ import { ComponentFixture, TestBed } from '@angular/core/testing' import { HomeComponent } from './home.component' -import { MemberService } from '../member/service/member.service' import { AccountService } from '../account' import { of } from 'rxjs' describe('HomeComponent', () => { let component: HomeComponent let fixture: ComponentFixture - let memberServiceSpy: jasmine.SpyObj let accountServiceSpy: jasmine.SpyObj beforeEach(() => { accountServiceSpy = jasmine.createSpyObj('AccountService', ['getAccountData']) - memberServiceSpy = jasmine.createSpyObj('MemberService', ['getMemberData']) TestBed.configureTestingModule({ declarations: [HomeComponent], - providers: [ - { provide: MemberService, useValue: memberServiceSpy }, - { provide: AccountService, useValue: accountServiceSpy }, - ], + providers: [{ provide: AccountService, useValue: accountServiceSpy }], }) fixture = TestBed.createComponent(HomeComponent) component = fixture.componentInstance accountServiceSpy = TestBed.inject(AccountService) as jasmine.SpyObj - memberServiceSpy = TestBed.inject(MemberService) as jasmine.SpyObj }) it('should call getAccountData but not getMemberData', () => { @@ -37,7 +30,7 @@ describe('HomeComponent', () => { component.ngOnInit() expect(accountServiceSpy.getAccountData).toHaveBeenCalled() - expect(memberServiceSpy.getMemberData).toHaveBeenCalledTimes(0) + expect(component.loggedInMessage).toBeUndefined() }) it('should call getMemberData if account data is not null', () => { @@ -57,13 +50,12 @@ describe('HomeComponent', () => { mfaEnabled: false, }) ) - memberServiceSpy.getMemberData.and.returnValue(of({})) expect(component).toBeTruthy() component.ngOnInit() expect(accountServiceSpy.getAccountData).toHaveBeenCalled() - expect(memberServiceSpy.getMemberData).toHaveBeenCalled() + expect(component.loggedInMessage).toEqual('You are logged in as user email@email.com') }) }) diff --git a/ui/src/app/home/home.component.ts b/ui/src/app/home/home.component.ts index 5fca0beef..c4655aab3 100644 --- a/ui/src/app/home/home.component.ts +++ b/ui/src/app/home/home.component.ts @@ -13,38 +13,24 @@ import { IAccount } from '../account/model/account.model' export class HomeComponent implements OnInit, OnDestroy { account: IAccount | undefined | null memberData: ISFMemberData | undefined | null - authenticationStateSubscription: Subscription | undefined - memberDataSubscription: Subscription | undefined - manageMemberSubscription: Subscription | undefined salesforceId: string | undefined loggedInMessage: string | undefined + accountServiceSubscription: Subscription | undefined - constructor( - private accountService: AccountService, - private memberService: MemberService - ) {} + constructor(private accountService: AccountService) {} ngOnInit() { - this.accountService.getAccountData().subscribe((account) => { + this.accountServiceSubscription = this.accountService.getAccountData().subscribe((account) => { this.account = account if (account) { - /* this.memberDataSubscription = this.memberService.getMemberData(account.salesforceId).subscribe((data) => { - this.memberData = data - }) */ this.loggedInMessage = $localize`:@@home.loggedIn.message.string:You are logged in as user ${account.email}` } }) } - ngOnDestroy() { - if (this.authenticationStateSubscription) { - this.authenticationStateSubscription.unsubscribe() + ngOnDestroy(): void { + if (this.accountServiceSubscription) { + this.accountServiceSubscription.unsubscribe() } - /* if (this.memberDataSubscription) { - this.memberDataSubscription.unsubscribe() - } */ - /* if (this.manageMemberSubscription) { - this.manageMemberSubscription.unsubscribe() - } */ } }