From 99af2846b9b0b12814acbe3148b5469a4f59cca8 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Wed, 2 Nov 2022 00:26:54 -0700 Subject: [PATCH] fixing tests. (#10) --- frontend/src/app/components/header/header.component.ts | 7 ++++++- .../app/pages/auth-signin/auth-signin.component.spec.ts | 2 +- .../src/lib/conduit/fhir/base/fhir401_r4_client.spec.ts | 4 ++-- frontend/src/lib/database/pouchdb_repository.spec.ts | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/components/header/header.component.ts b/frontend/src/app/components/header/header.component.ts index d2b68a1e..72e65917 100644 --- a/frontend/src/app/components/header/header.component.ts +++ b/frontend/src/app/components/header/header.component.ts @@ -12,7 +12,12 @@ export class HeaderComponent implements OnInit { constructor(private authService: AuthService, private router: Router) { } ngOnInit() { - this.current_user = this.authService.GetCurrentUser() + try { + this.current_user = this.authService.GetCurrentUser() + } catch(e){ + this.current_user = "unknown" + } + } closeMenu(e) { diff --git a/frontend/src/app/pages/auth-signin/auth-signin.component.spec.ts b/frontend/src/app/pages/auth-signin/auth-signin.component.spec.ts index 97f0b822..b5e22516 100644 --- a/frontend/src/app/pages/auth-signin/auth-signin.component.spec.ts +++ b/frontend/src/app/pages/auth-signin/auth-signin.component.spec.ts @@ -13,7 +13,7 @@ describe('AuthSigninComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ declarations: [ AuthSigninComponent ], - imports: [HttpClientTestingModule, FormsModule], + imports: [HttpClientTestingModule, FormsModule, RouterTestingModule], }) .compileComponents(); diff --git a/frontend/src/lib/conduit/fhir/base/fhir401_r4_client.spec.ts b/frontend/src/lib/conduit/fhir/base/fhir401_r4_client.spec.ts index 4425b288..19fd2142 100644 --- a/frontend/src/lib/conduit/fhir/base/fhir401_r4_client.spec.ts +++ b/frontend/src/lib/conduit/fhir/base/fhir401_r4_client.spec.ts @@ -68,10 +68,10 @@ describe('FHIR401Client', () => { let repository: IDatabaseRepository; beforeEach(async () => { - let current_user = uuidv4() + let current_user = uuidv4() as string let cryptoConfig = await PouchdbCrypto.CryptConfig(current_user, current_user) await PouchdbCrypto.StoreCryptConfig(cryptoConfig) - repository = NewPouchdbRepositoryWebWorker(current_user, '/database', new PouchDB("FHIR401Client-"+ current_user)); + repository = NewPouchdbRepositoryWebWorker({current_user: current_user, auth_token:""}, '/database', new PouchDB("FHIR401Client-"+ current_user)); }); afterEach(async () => { diff --git a/frontend/src/lib/database/pouchdb_repository.spec.ts b/frontend/src/lib/database/pouchdb_repository.spec.ts index 5e09f67f..e717ebc6 100644 --- a/frontend/src/lib/database/pouchdb_repository.spec.ts +++ b/frontend/src/lib/database/pouchdb_repository.spec.ts @@ -11,10 +11,10 @@ describe('PouchdbRepository', () => { let repository: IDatabaseRepository; beforeEach(async () => { - let current_user = uuidv4() + let current_user = uuidv4() as string let cryptoConfig = await PouchdbCrypto.CryptConfig(current_user, current_user) await PouchdbCrypto.StoreCryptConfig(cryptoConfig) - repository = NewPouchdbRepositoryWebWorker(current_user, '/database', new PouchDB("PouchdbRepository" + current_user)); + repository = NewPouchdbRepositoryWebWorker({current_user: current_user, auth_token: ""}, '/database', new PouchDB("PouchdbRepository" + current_user)); }); afterEach(async () => {