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

View File

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

View File

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

View File

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

View File

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

View File

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