From 96410d88d80d0e2ec83cec9aeee13d460c94186b Mon Sep 17 00:00:00 2001
From: Martin <git@mail.de>
Date: Mon, 20 Jan 2025 12:25:02 +0100
Subject: [PATCH] OZG-6986 rename Functions

---
 .../src/lib/authentication.service.spec.ts    | 42 +++++++++----------
 .../src/lib/authentication.service.ts         | 12 +++---
 2 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/alfa-client/libs/authentication/src/lib/authentication.service.spec.ts b/alfa-client/libs/authentication/src/lib/authentication.service.spec.ts
index 14b3984a18..486415f425 100644
--- a/alfa-client/libs/authentication/src/lib/authentication.service.spec.ts
+++ b/alfa-client/libs/authentication/src/lib/authentication.service.spec.ts
@@ -55,7 +55,7 @@ describe('AuthenticationService', () => {
 
   describe('login', () => {
     beforeEach(() => {
-      service.buildEventPromise = jest.fn();
+      service.buildAuthEventPromise = jest.fn();
     });
 
     it('should configure service with authConfig', async () => {
@@ -81,12 +81,12 @@ describe('AuthenticationService', () => {
       expect(oAuthService.tokenValidationHandler).not.toBeNull();
     });
 
-    it('should build event promise', async () => {
-      service.buildEventPromise = jest.fn().mockResolvedValue(() => Promise.resolve());
+    it('should build auth event promise', async () => {
+      service.buildAuthEventPromise = jest.fn().mockResolvedValue(() => Promise.resolve());
 
       await service.login();
 
-      expect(service.buildEventPromise).toHaveBeenCalled();
+      expect(service.buildAuthEventPromise).toHaveBeenCalled();
     });
 
     it('should load discovery document and login', () => {
@@ -97,7 +97,7 @@ describe('AuthenticationService', () => {
 
     it('should return eventPromise', async () => {
       const promise: Promise<void> = Promise.resolve();
-      service.buildEventPromise = jest.fn().mockResolvedValue(promise);
+      service.buildAuthEventPromise = jest.fn().mockResolvedValue(promise);
 
       const returnPromise: Promise<void> = service.login();
 
@@ -105,39 +105,39 @@ describe('AuthenticationService', () => {
     });
   });
 
-  describe('build event promise', () => {
+  describe('build auth event promise', () => {
     const event: OAuthEvent = createOAuthEvent();
 
     beforeEach(() => {
-      service.shouldProceedByType = jest.fn().mockReturnValue(true);
+      service.shouldProceedByAuthEvent = jest.fn().mockReturnValue(true);
       service.setCurrentUser = jest.fn();
       service.unsubscribeEvents = jest.fn();
     });
 
-    it('should call shouldProceedByType on event trigger', () => {
-      service.buildEventPromise();
+    it('should call shouldProceedByAuthEvent on event trigger', () => {
+      service.buildAuthEventPromise();
       eventsSubject.next(event);
 
-      expect(service.shouldProceedByType).toHaveBeenCalledWith(event);
+      expect(service.shouldProceedByAuthEvent).toHaveBeenCalledWith(event);
     });
 
     describe('on next', () => {
       it('should set current user', () => {
-        service.buildEventPromise();
+        service.buildAuthEventPromise();
         eventsSubject.next(event);
 
         expect(service.setCurrentUser).toHaveBeenCalled();
       });
 
       it('should unsubscribe event', () => {
-        service.buildEventPromise();
+        service.buildAuthEventPromise();
         eventsSubject.next(event);
 
         expect(service.unsubscribeEvents).toHaveBeenCalled();
       });
 
       it('should resolved promise with a valid event', async () => {
-        const promise: Promise<void> = service.buildEventPromise();
+        const promise: Promise<void> = service.buildAuthEventPromise();
         eventsSubject.next(event);
 
         await expect(promise).resolves.toBeUndefined();
@@ -149,14 +149,14 @@ describe('AuthenticationService', () => {
       const error: Error = new Error(errorMessage);
 
       it('should unsubscribe event', () => {
-        service.buildEventPromise();
+        service.buildAuthEventPromise();
         eventsSubject.error(error);
 
         expect(service.unsubscribeEvents).toHaveBeenCalled();
       });
 
       it('should reject the promise with an error', async () => {
-        const promise: Promise<void> = service.buildEventPromise();
+        const promise: Promise<void> = service.buildAuthEventPromise();
 
         eventsSubject.error(error);
 
@@ -165,13 +165,13 @@ describe('AuthenticationService', () => {
     });
   });
 
-  describe('should proceed by type', () => {
+  describe('should proceed by auth event', () => {
     const event: OAuthEvent = createOAuthEvent();
 
     it('should call considered as login event', () => {
       service.consideredAsLoginEvent = jest.fn();
 
-      service.shouldProceedByType(event);
+      service.shouldProceedByAuthEvent(event);
 
       expect(service.consideredAsLoginEvent).toHaveBeenCalledWith(event.type);
     });
@@ -179,7 +179,7 @@ describe('AuthenticationService', () => {
     it('should return true on login event', () => {
       service.consideredAsLoginEvent = jest.fn().mockReturnValue(true);
 
-      const proceed: boolean = service.shouldProceedByType(event);
+      const proceed: boolean = service.shouldProceedByAuthEvent(event);
 
       expect(proceed).toBeTruthy();
     });
@@ -188,7 +188,7 @@ describe('AuthenticationService', () => {
       service.consideredAsLoginEvent = jest.fn().mockReturnValue(false);
       service.consideredAsPageReloadEvent = jest.fn();
 
-      service.shouldProceedByType(event);
+      service.shouldProceedByAuthEvent(event);
 
       expect(service.consideredAsPageReloadEvent).toHaveBeenCalledWith(event.type);
     });
@@ -197,7 +197,7 @@ describe('AuthenticationService', () => {
       service.consideredAsLoginEvent = jest.fn().mockReturnValue(false);
       service.consideredAsPageReloadEvent = jest.fn().mockReturnValue(true);
 
-      const proceed: boolean = service.shouldProceedByType(event);
+      const proceed: boolean = service.shouldProceedByAuthEvent(event);
 
       expect(proceed).toBeTruthy();
     });
@@ -206,7 +206,7 @@ describe('AuthenticationService', () => {
       service.consideredAsLoginEvent = jest.fn().mockReturnValue(false);
       service.consideredAsPageReloadEvent = jest.fn().mockReturnValue(false);
 
-      const proceed: boolean = service.shouldProceedByType(event);
+      const proceed: boolean = service.shouldProceedByAuthEvent(event);
 
       expect(proceed).toBeFalsy();
     });
diff --git a/alfa-client/libs/authentication/src/lib/authentication.service.ts b/alfa-client/libs/authentication/src/lib/authentication.service.ts
index b22baa5b45..e350dcafe7 100644
--- a/alfa-client/libs/authentication/src/lib/authentication.service.ts
+++ b/alfa-client/libs/authentication/src/lib/authentication.service.ts
@@ -45,18 +45,18 @@ export class AuthenticationService {
     this.oAuthService.setupAutomaticSilentRefresh();
     this.oAuthService.tokenValidationHandler = new JwksValidationHandler();
 
-    const eventPromise: Promise<void> = this.buildEventPromise();
+    const eventPromise: Promise<void> = this.buildAuthEventPromise();
     await this.oAuthService.loadDiscoveryDocumentAndLogin();
     return eventPromise;
   }
 
-  buildEventPromise(): Promise<void> {
-    return new Promise<void>((resolve, reject) => this.handleOAuthEventsForPromise(resolve, reject));
+  buildAuthEventPromise(): Promise<void> {
+    return new Promise<void>((resolve, reject) => this.handleAuthEventsForPromise(resolve, reject));
   }
 
-  private handleOAuthEventsForPromise(resolve: (value: void | PromiseLike<void>) => void, reject: (reason?: any) => void): void {
+  private handleAuthEventsForPromise(resolve: (value: void | PromiseLike<void>) => void, reject: (reason?: any) => void): void {
     this.eventSubscription = this.oAuthService.events
-      .pipe(filter((event: OAuthEvent) => this.shouldProceedByType(event)))
+      .pipe(filter((event: OAuthEvent) => this.shouldProceedByAuthEvent(event)))
       .subscribe({
         next: () => {
           this.setCurrentUser();
@@ -70,7 +70,7 @@ export class AuthenticationService {
       });
   }
 
-  shouldProceedByType(event: OAuthEvent): boolean {
+  shouldProceedByAuthEvent(event: OAuthEvent): boolean {
     return this.consideredAsLoginEvent(event.type) || this.consideredAsPageReloadEvent(event.type);
   }
 
-- 
GitLab