Skip to content

Commit

Permalink
refactor test
Browse files Browse the repository at this point in the history
  • Loading branch information
artlowel committed Apr 30, 2024
1 parent f63aea1 commit 6be506f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ describe('singleFeatureAuthorizationGuard', () => {


result$.subscribe(() => {
expect(authorizationService.isAuthorized).toHaveBeenCalledWith(featureId, objectUrl, ePersonUuid);
done();
expect(authorizationService.isAuthorized).toHaveBeenCalled

Check failure on line 59 in src/app/core/data/feature-authorization/feature-authorization-guard/single-feature-authorization.guard.spec.ts

View workflow job for this annotation

GitHub Actions / tests (16.x)

Expected an assignment or function call and instead saw an expression

Check failure on line 59 in src/app/core/data/feature-authorization/feature-authorization-guard/single-feature-authorization.guard.spec.ts

View workflow job for this annotation

GitHub Actions / tests (16.x)

Missing semicolon

Check failure on line 59 in src/app/core/data/feature-authorization/feature-authorization-guard/single-feature-authorization.guard.spec.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Expected an assignment or function call and instead saw an expression

Check failure on line 59 in src/app/core/data/feature-authorization/feature-authorization-guard/single-feature-authorization.guard.spec.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Missing semicolon
})

Check failure on line 60 in src/app/core/data/feature-authorization/feature-authorization-guard/single-feature-authorization.guard.spec.ts

View workflow job for this annotation

GitHub Actions / tests (16.x)

Missing semicolon

Check failure on line 60 in src/app/core/data/feature-authorization/feature-authorization-guard/single-feature-authorization.guard.spec.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Missing semicolon
});

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -41,6 +42,12 @@ describe('someFeatureAuthorizationGuard', () => {
{ provide: AuthService, useValue: authService },
]
});

guard = someFeatureAuthorizationGuard(
() => observableOf(featureIds),
() => observableOf(objectUrl),
() => observableOf(ePersonUuid),
);
}

beforeEach(waitForAsync(() => {
Expand All @@ -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)

Check failure on line 64 in src/app/core/data/feature-authorization/feature-authorization-guard/some-feature-authorization.guard.spec.ts

View workflow job for this annotation

GitHub Actions / tests (16.x)

Missing semicolon

Check failure on line 64 in src/app/core/data/feature-authorization/feature-authorization-guard/some-feature-authorization.guard.spec.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Missing semicolon
}) as Observable<boolean | UrlTree>;

result$.subscribe((result) => {
Expand All @@ -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)

Check failure on line 81 in src/app/core/data/feature-authorization/feature-authorization-guard/some-feature-authorization.guard.spec.ts

View workflow job for this annotation

GitHub Actions / tests (16.x)

Missing semicolon

Check failure on line 81 in src/app/core/data/feature-authorization/feature-authorization-guard/some-feature-authorization.guard.spec.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Missing semicolon
}) as Observable<boolean | UrlTree>;

result$.subscribe((result) => {
Expand All @@ -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)

Check failure on line 98 in src/app/core/data/feature-authorization/feature-authorization-guard/some-feature-authorization.guard.spec.ts

View workflow job for this annotation

GitHub Actions / tests (16.x)

Missing semicolon

Check failure on line 98 in src/app/core/data/feature-authorization/feature-authorization-guard/some-feature-authorization.guard.spec.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Missing semicolon
}) as Observable<boolean | UrlTree>;

result$.subscribe((result) => {
Expand Down

0 comments on commit 6be506f

Please sign in to comment.