Fixed related unit test

This commit is contained in:
VitoAlbano 2024-10-14 13:40:18 +01:00
parent 98359e1073
commit c0ce6f70b3
6 changed files with 11 additions and 5 deletions

View File

@ -27,6 +27,8 @@ import { EMPTY, of } from 'rxjs';
import { OidcAuthenticationService } from '../oidc/oidc-authentication.service';
import { AuthGuardService } from './auth-guard.service';
import { NoopTranslateModule } from '../../testing/noop-translate.module';
import { JWT_STORAGE_SERVICE } from '../public-api';
import { StorageService } from '../../common';
describe('AuthGuardService BPM', () => {
let authGuard: Promise<boolean>;
@ -45,6 +47,7 @@ describe('AuthGuardService BPM', () => {
providers: [
AuthGuardService,
{ provide: RedirectAuthService, useValue: { onLogin: EMPTY, onTokenReceived: of() } },
{ provide: JWT_STORAGE_SERVICE, useClass: StorageService },
{
provide: OidcAuthenticationService,
useValue: {

View File

@ -27,6 +27,8 @@ import { RedirectAuthService } from '../oidc/redirect-auth.service';
import { EMPTY, of } from 'rxjs';
import { OidcAuthenticationService } from '../oidc/oidc-authentication.service';
import { NoopTranslateModule } from '../../testing/noop-translate.module';
import { JWT_STORAGE_SERVICE } from '../public-api';
import { StorageService } from '../../common';
describe('AuthGuardService ECM', () => {
let authGuard: Promise<boolean>;
@ -54,7 +56,8 @@ describe('AuthGuardService ECM', () => {
shouldPerformSsoLogin$: of(true)
}
},
{ provide: RedirectAuthService, useValue: { onLogin: EMPTY, onTokenReceived: of() } }
{ provide: RedirectAuthService, useValue: { onLogin: EMPTY, onTokenReceived: of() } },
{ provide: JWT_STORAGE_SERVICE, useClass: StorageService }
]
});
localStorage.clear();

View File

@ -28,6 +28,7 @@ import { EMPTY, of } from 'rxjs';
import { MatDialogModule } from '@angular/material/dialog';
import { RouterTestingModule } from '@angular/router/testing';
import { NoopTranslateModule } from '../../testing/noop-translate.module';
import { JWT_STORAGE_SERVICE } from '../public-api';
describe('AuthGuardService', () => {
let state: RouterStateSnapshot;
@ -45,7 +46,7 @@ describe('AuthGuardService', () => {
imports: [NoopTranslateModule, MatDialogModule, RouterTestingModule],
providers: [
AppConfigService,
StorageService,
{ provide: JWT_STORAGE_SERVICE, useClass: StorageService },
{ provide: RedirectAuthService, useValue: { onLogin: EMPTY, onTokenReceived: of() } },
{
provide: OidcAuthenticationService,

View File

@ -65,7 +65,6 @@ describe('OidcAuthenticationService', () => {
{ provide: OAuthService, useClass: MockOAuthService },
{ provide: OAuthStorage, useValue: {} },
{ provide: AUTH_MODULE_CONFIG, useValue: {} },
{ provide: AuthService, useValue: {} }
]
});
service = TestBed.inject(OidcAuthenticationService);

View File

@ -42,7 +42,7 @@ describe('JwtHelperService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [JwtHelperService, { provide: StorageService, useValue: mockStorage }]
providers: [JwtHelperService, { provide: JWT_STORAGE_SERVICE, useValue: mockStorage }]
});
jwtHelperService = TestBed.inject(JwtHelperService);
});

View File

@ -30,7 +30,7 @@ describe('UserAccessService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [UserAccessService, { provide: JWT_STORAGE_SERVICE, useValue: StorageService }]
providers: [{ provide: JWT_STORAGE_SERVICE, useClass: StorageService }, UserAccessService]
});
userAccessService = TestBed.inject(UserAccessService);
jwtHelperService = TestBed.inject(JwtHelperService);