Fixed related unit test

This commit is contained in:
VitoAlbano
2024-10-14 13:18:32 +01:00
parent 1869b78e0e
commit 98359e1073
4 changed files with 12 additions and 6 deletions

View File

@@ -21,6 +21,7 @@ import { AuthGuardSsoRoleService } from './auth-guard-sso-role.service';
import { JwtHelperService, JWT_STORAGE_SERVICE } from '../services/jwt-helper.service'; import { JwtHelperService, JWT_STORAGE_SERVICE } from '../services/jwt-helper.service';
import { MatDialog, MatDialogModule } from '@angular/material/dialog'; import { MatDialog, MatDialogModule } from '@angular/material/dialog';
import { NoopTranslateModule } from '../../testing/noop-translate.module'; import { NoopTranslateModule } from '../../testing/noop-translate.module';
import { StorageService } from '../../common';
describe('Auth Guard SSO role service', () => { describe('Auth Guard SSO role service', () => {
let jwtHelperService: JwtHelperService; let jwtHelperService: JwtHelperService;
@@ -30,7 +31,7 @@ describe('Auth Guard SSO role service', () => {
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [NoopTranslateModule, MatDialogModule], imports: [NoopTranslateModule, MatDialogModule],
providers: [{ provide: JWT_STORAGE_SERVICE, useValue: { getItem: () => {}, setItem: () => {}, removeItem: () => {} } }] providers: [{ provide: JWT_STORAGE_SERVICE, useClass: StorageService }]
}); });
localStorage.clear(); localStorage.clear();
jwtHelperService = TestBed.inject(JwtHelperService); jwtHelperService = TestBed.inject(JwtHelperService);

View File

@@ -20,6 +20,7 @@ import { UserAccessService } from './user-access.service';
import { JwtHelperService, JWT_STORAGE_SERVICE } from './jwt-helper.service'; import { JwtHelperService, JWT_STORAGE_SERVICE } from './jwt-helper.service';
import { AppConfigService } from '../../app-config'; import { AppConfigService } from '../../app-config';
import { HttpClientTestingModule } from '@angular/common/http/testing'; import { HttpClientTestingModule } from '@angular/common/http/testing';
import { StorageService } from '../../common';
describe('UserAccessService', () => { describe('UserAccessService', () => {
let userAccessService: UserAccessService; let userAccessService: UserAccessService;
@@ -29,7 +30,7 @@ describe('UserAccessService', () => {
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [HttpClientTestingModule], imports: [HttpClientTestingModule],
providers: [UserAccessService, { provide: JWT_STORAGE_SERVICE, useValue: {} }] providers: [UserAccessService, { provide: JWT_STORAGE_SERVICE, useValue: StorageService }]
}); });
userAccessService = TestBed.inject(UserAccessService); userAccessService = TestBed.inject(UserAccessService);
jwtHelperService = TestBed.inject(JwtHelperService); jwtHelperService = TestBed.inject(JwtHelperService);

View File

@@ -16,7 +16,7 @@
*/ */
import { AlfrescoApiService } from '@alfresco/adf-content-services'; import { AlfrescoApiService } from '@alfresco/adf-content-services';
import { ADF_DATE_FORMATS, FullNamePipe, NoopTranslateModule, UserPreferencesService } from '@alfresco/adf-core'; import { ADF_DATE_FORMATS, FullNamePipe, JWT_STORAGE_SERVICE, NoopTranslateModule, StorageService, UserPreferencesService } from '@alfresco/adf-core';
import { HarnessLoader } from '@angular/cdk/testing'; import { HarnessLoader } from '@angular/cdk/testing';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { SimpleChange } from '@angular/core'; import { SimpleChange } from '@angular/core';
@@ -121,7 +121,8 @@ describe('EditProcessFilterCloudComponent', () => {
{ provide: DateAdapter, useClass: DateFnsAdapter }, { provide: DateAdapter, useClass: DateFnsAdapter },
{ provide: NotificationCloudService, useValue: { makeGQLQuery: () => of([]) } }, { provide: NotificationCloudService, useValue: { makeGQLQuery: () => of([]) } },
{ provide: MAT_DATE_FORMATS, useValue: ADF_DATE_FORMATS }, { provide: MAT_DATE_FORMATS, useValue: ADF_DATE_FORMATS },
{ provide: IDENTITY_USER_SERVICE_TOKEN, useExisting: IdentityUserServiceMock } { provide: IDENTITY_USER_SERVICE_TOKEN, useExisting: IdentityUserServiceMock },
{ provide: JWT_STORAGE_SERVICE, useClass: StorageService }
], ],
declarations: [PeopleCloudComponent, DateRangeFilterComponent] declarations: [PeopleCloudComponent, DateRangeFilterComponent]
}); });

View File

@@ -24,7 +24,9 @@ import {
TranslationService, TranslationService,
TranslationMock, TranslationMock,
CoreModule, CoreModule,
AuthModule AuthModule,
JWT_STORAGE_SERVICE,
StorageService
} from '@alfresco/adf-core'; } from '@alfresco/adf-core';
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services'; import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
@@ -44,7 +46,8 @@ import { RouterTestingModule } from '@angular/router/testing';
providers: [ providers: [
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }, { provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
{ provide: AppConfigService, useClass: AppConfigServiceMock }, { provide: AppConfigService, useClass: AppConfigServiceMock },
{ provide: TranslationService, useClass: TranslationMock } { provide: TranslationService, useClass: TranslationMock },
{ provide: JWT_STORAGE_SERVICE, useClass: StorageService }
], ],
exports: [NoopAnimationsModule, TranslateModule, CoreModule, ProcessServicesCloudModule] exports: [NoopAnimationsModule, TranslateModule, CoreModule, ProcessServicesCloudModule]
}) })