mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-09-24 14:31:41 +00:00
fix unit
This commit is contained in:
@@ -234,6 +234,8 @@ export class AppConfigService {
|
||||
resolve(res);
|
||||
},
|
||||
error: (err: any) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('hostIdp not correctly configured or unreachable');
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
|
@@ -25,7 +25,7 @@ import {
|
||||
FormModel,
|
||||
FormOutcomeEvent,
|
||||
FormOutcomeModel, FormRenderingService, FormService,
|
||||
UploadWidgetContentLinkModel, WidgetVisibilityService, provideTranslations
|
||||
UploadWidgetContentLinkModel, WidgetVisibilityService, provideTranslations, AuthModule
|
||||
} from '@alfresco/adf-core';
|
||||
import { Node } from '@alfresco/js-api';
|
||||
import { ESCAPE } from '@angular/cdk/keycodes';
|
||||
@@ -1151,6 +1151,7 @@ describe('Multilingual Form', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
AuthModule.forRoot({ useHash: true }),
|
||||
NoopAnimationsModule,
|
||||
TranslateModule.forRoot(),
|
||||
CoreModule.forRoot(),
|
||||
|
@@ -17,9 +17,7 @@
|
||||
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { JwtHelperService } from '@alfresco/adf-core';
|
||||
import { IdentityUserService } from './identity-user.service';
|
||||
import { mockToken } from '../mock/jwt-helper.service.spec';
|
||||
import { ProcessServiceCloudTestingModule } from '../../testing/process-service-cloud.testing.module';
|
||||
import {
|
||||
mockSearchUserByApp,
|
||||
@@ -52,37 +50,6 @@ describe('IdentityUserService', () => {
|
||||
requestSpy = spyOn(adfHttpClient, 'request');
|
||||
});
|
||||
|
||||
describe('Current user info (JWT token)', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
const store = {};
|
||||
|
||||
spyOn(localStorage, 'getItem').and.callFake((key: string): string => store[key] || null);
|
||||
spyOn(localStorage, 'setItem').and.callFake((key: string, value: string): string => store[key] = value);
|
||||
});
|
||||
|
||||
it('should fetch identity user info from Jwt id token', () => {
|
||||
localStorage.setItem(JwtHelperService.USER_ID_TOKEN, mockToken);
|
||||
const user = service.getCurrentUserInfo();
|
||||
expect(user).toBeDefined();
|
||||
expect(user.firstName).toEqual('John');
|
||||
expect(user.lastName).toEqual('Doe');
|
||||
expect(user.email).toEqual('johnDoe@gmail.com');
|
||||
expect(user.username).toEqual('johnDoe1');
|
||||
});
|
||||
|
||||
it('should fallback on Jwt access token for identity user info', () => {
|
||||
localStorage.setItem(JwtHelperService.USER_ACCESS_TOKEN, mockToken);
|
||||
const user = service.getCurrentUserInfo();
|
||||
expect(user).toBeDefined();
|
||||
expect(user.firstName).toEqual('John');
|
||||
expect(user.lastName).toEqual('Doe');
|
||||
expect(user.email).toEqual('johnDoe@gmail.com');
|
||||
expect(user.username).toEqual('johnDoe1');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Search', () => {
|
||||
|
||||
it('should fetch users', (done) => {
|
||||
|
@@ -21,7 +21,7 @@ import { ContentModule, ContentNodeSelectorPanelComponent, DocumentListService,
|
||||
import { EventEmitter, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { ProcessTestingModule } from '../../../testing/process.testing.module';
|
||||
import { AttachFileWidgetDialogComponent } from './attach-file-widget-dialog.component';
|
||||
import { AlfrescoApiService, BasicAlfrescoAuthService, AuthenticationService } from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService, BasicAlfrescoAuthService } from '@alfresco/adf-core';
|
||||
import { AttachFileWidgetDialogComponentData } from './attach-file-widget-dialog-component.interface';
|
||||
import { of, throwError } from 'rxjs';
|
||||
import { By } from '@angular/platform-browser';
|
||||
@@ -47,7 +47,6 @@ describe('AttachFileWidgetDialogComponent', () => {
|
||||
let documentListService: DocumentListService;
|
||||
let apiService: AlfrescoApiService;
|
||||
let matDialogRef: MatDialogRef<AttachFileWidgetDialogComponent>;
|
||||
let authService: AuthenticationService;
|
||||
|
||||
let isLogged = false;
|
||||
const fakeSite = new SiteEntry({ entry: { id: 'fake-site', guid: 'fake-site', title: 'fake-site', visibility: 'visible' } });
|
||||
@@ -75,7 +74,6 @@ describe('AttachFileWidgetDialogComponent', () => {
|
||||
documentListService = fixture.debugElement.injector.get(DocumentListService);
|
||||
matDialogRef = fixture.debugElement.injector.get(MatDialogRef);
|
||||
apiService = fixture.debugElement.injector.get(AlfrescoApiService);
|
||||
authService = fixture.debugElement.injector.get(AuthenticationService);
|
||||
|
||||
spyOn(documentListService, 'getFolderNode').and.returnValue(of({ entry: { path: { elements: [] } } } as NodeEntry));
|
||||
spyOn(documentListService, 'getFolder').and.returnValue(throwError('No results for test'));
|
||||
@@ -197,7 +195,7 @@ describe('AttachFileWidgetDialogComponent', () => {
|
||||
passwordInput.dispatchEvent(new Event('input'));
|
||||
loginButton.click();
|
||||
|
||||
authService.onLogin.next('logged In');
|
||||
basicAlfrescoAuthService.onLogin.next('logged-in');
|
||||
fixture.detectChanges();
|
||||
expect(matDialogRef.close).toHaveBeenCalled();
|
||||
});
|
||||
|
Reference in New Issue
Block a user