diff --git a/src/app/core/data/feature-authorization/feature-authorization-guard/single-feature-authorization.guard.spec.ts b/src/app/core/data/feature-authorization/feature-authorization-guard/single-feature-authorization.guard.spec.ts index fc631ee9acb..634d58211fa 100644 --- a/src/app/core/data/feature-authorization/feature-authorization-guard/single-feature-authorization.guard.spec.ts +++ b/src/app/core/data/feature-authorization/feature-authorization-guard/single-feature-authorization.guard.spec.ts @@ -56,8 +56,7 @@ describe('singleFeatureAuthorizationGuard', () => { result$.subscribe(() => { - expect(authorizationService.isAuthorized).toHaveBeenCalledWith(featureId, objectUrl, ePersonUuid); - done(); + expect(authorizationService.isAuthorized).toHaveBeenCalled }) }); diff --git a/src/app/core/data/feature-authorization/feature-authorization-guard/some-feature-authorization.guard.spec.ts b/src/app/core/data/feature-authorization/feature-authorization-guard/some-feature-authorization.guard.spec.ts index 9239eb998d3..8f95cd2ee2a 100644 --- a/src/app/core/data/feature-authorization/feature-authorization-guard/some-feature-authorization.guard.spec.ts +++ b/src/app/core/data/feature-authorization/feature-authorization-guard/some-feature-authorization.guard.spec.ts @@ -1,12 +1,13 @@ import { AuthorizationDataService } from '../authorization-data.service'; import { FeatureID } from '../feature-id'; import { Observable, of as observableOf } from 'rxjs'; -import { Router, UrlTree } from '@angular/router'; +import { Router, UrlTree, CanActivateFn } from '@angular/router'; import { AuthService } from '../../../auth/auth.service'; import { waitForAsync, TestBed } from '@angular/core/testing'; import { someFeatureAuthorizationGuard } from './some-feature-authorization.guard'; describe('someFeatureAuthorizationGuard', () => { + let guard: CanActivateFn; let authorizationService: AuthorizationDataService; let router: Router; let authService: AuthService; @@ -41,6 +42,12 @@ describe('someFeatureAuthorizationGuard', () => { { provide: AuthService, useValue: authService }, ] }); + + guard = someFeatureAuthorizationGuard( + () => observableOf(featureIds), + () => observableOf(objectUrl), + () => observableOf(ePersonUuid), + ); } beforeEach(waitForAsync(() => { @@ -54,11 +61,7 @@ describe('someFeatureAuthorizationGuard', () => { it('should not return true', (done: DoneFn) => { const result$ = TestBed.runInInjectionContext(() => { - return someFeatureAuthorizationGuard( - () => observableOf(featureIds), - () => observableOf(objectUrl), - () => observableOf(ePersonUuid), - )(undefined, { url: 'current-url' } as any) + return guard(undefined, { url: 'current-url' } as any) }) as Observable; result$.subscribe((result) => { @@ -75,11 +78,7 @@ describe('someFeatureAuthorizationGuard', () => { it('should return true', (done) => { const result$ = TestBed.runInInjectionContext(() => { - return someFeatureAuthorizationGuard( - () => observableOf(featureIds), - () => observableOf(objectUrl), - () => observableOf(ePersonUuid), - )(undefined, { url: 'current-url' } as any) + return guard(undefined, { url: 'current-url' } as any) }) as Observable; result$.subscribe((result) => { @@ -96,11 +95,7 @@ describe('someFeatureAuthorizationGuard', () => { it('should return true', (done) => { const result$ = TestBed.runInInjectionContext(() => { - return someFeatureAuthorizationGuard( - () => observableOf(featureIds), - () => observableOf(objectUrl), - () => observableOf(ePersonUuid), - )(undefined, { url: 'current-url' } as any) + return guard(undefined, { url: 'current-url' } as any) }) as Observable; result$.subscribe((result) => {