mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-09-17 14:21:29 +00:00
Fixed unit tests
This commit is contained in:
@@ -21,6 +21,7 @@ import { AuthGuardSsoRoleService } from './auth-guard-sso-role.service';
|
||||
import { JwtHelperService } from '../services/jwt-helper.service';
|
||||
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
|
||||
import { NoopTranslateModule } from '../../testing/noop-translate.module';
|
||||
import { AuthModule } from '../oidc/auth.module';
|
||||
|
||||
describe('Auth Guard SSO role service', () => {
|
||||
let jwtHelperService: JwtHelperService;
|
||||
@@ -29,7 +30,7 @@ describe('Auth Guard SSO role service', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, MatDialogModule]
|
||||
imports: [NoopTranslateModule, MatDialogModule, AuthModule.forRoot({ useHash: true })]
|
||||
});
|
||||
localStorage.clear();
|
||||
jwtHelperService = TestBed.inject(JwtHelperService);
|
||||
|
@@ -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 { NoopAuthModule } from '../../testing';
|
||||
|
||||
describe('AuthGuardService', () => {
|
||||
let state: RouterStateSnapshot;
|
||||
@@ -42,10 +43,10 @@ describe('AuthGuardService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, MatDialogModule, RouterTestingModule],
|
||||
imports: [NoopTranslateModule, MatDialogModule, RouterTestingModule, NoopAuthModule],
|
||||
providers: [
|
||||
AppConfigService,
|
||||
{ provide: RedirectAuthService, useValue: { onLogin: EMPTY, onTokenReceived: of() } },
|
||||
{ provide: RedirectAuthService, useValue: { onLogin: EMPTY, onTokenReceived: of(), init: () => {} } },
|
||||
{
|
||||
provide: OidcAuthenticationService,
|
||||
useValue: {
|
||||
|
@@ -35,6 +35,7 @@ import { IdentityRoleModel } from '../models/identity-role.model';
|
||||
import { AdfHttpClient } from '../../../../api/src';
|
||||
import { StorageService } from '../../common/services/storage.service';
|
||||
import { NoopTranslateModule } from '../../testing/noop-translate.module';
|
||||
import { OAuthStorage } from 'angular-oauth2-oidc';
|
||||
|
||||
describe('IdentityUserService', () => {
|
||||
const mockRoles = [
|
||||
@@ -53,7 +54,7 @@ describe('IdentityUserService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule],
|
||||
providers: [AdfHttpClient]
|
||||
providers: [AdfHttpClient, { provide: OAuthStorage, useClass: StorageService }]
|
||||
});
|
||||
storageService = TestBed.inject(StorageService);
|
||||
service = TestBed.inject(IdentityUserService);
|
||||
|
@@ -20,7 +20,6 @@ import { mockToken } from '../mock/jwt-helper.service.spec';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { StorageService } from '../../common';
|
||||
import { OAuthStorage } from 'angular-oauth2-oidc';
|
||||
import { JWT_STORAGE_SERVICE } from '../oidc/auth.module';
|
||||
|
||||
const mockStorage = {
|
||||
access_token: 'my-access_token',
|
||||
@@ -43,7 +42,7 @@ describe('JwtHelperService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [JwtHelperService, { provide: JWT_STORAGE_SERVICE, useValue: mockStorage }]
|
||||
providers: [JwtHelperService, { provide: OAuthStorage, useValue: mockStorage }]
|
||||
});
|
||||
jwtHelperService = TestBed.inject(JwtHelperService);
|
||||
});
|
||||
@@ -141,15 +140,11 @@ describe('JwtHelperService with custom storage service', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [
|
||||
JwtHelperService,
|
||||
{ provide: StorageService, useValue: mockStorage },
|
||||
{ provide: JWT_STORAGE_SERVICE, useValue: mockCustomStorage }
|
||||
]
|
||||
providers: [JwtHelperService, { provide: StorageService, useValue: mockStorage }, { provide: OAuthStorage, useValue: mockCustomStorage }]
|
||||
});
|
||||
jwtHelperService = TestBed.inject(JwtHelperService);
|
||||
defaultStorage = TestBed.inject(StorageService);
|
||||
customStorage = TestBed.inject(JWT_STORAGE_SERVICE);
|
||||
customStorage = TestBed.inject(OAuthStorage);
|
||||
});
|
||||
|
||||
it('should use the custom storage service', () => {
|
||||
|
@@ -20,7 +20,8 @@ import { UserAccessService } from './user-access.service';
|
||||
import { JwtHelperService } from './jwt-helper.service';
|
||||
import { AppConfigService } from '../../app-config';
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { StorageService } from '../../common';
|
||||
import { AuthModule, JWT_STORAGE_SERVICE } from '../oidc/auth.module';
|
||||
import { StorageService } from '../../common/services/storage.service';
|
||||
|
||||
describe('UserAccessService', () => {
|
||||
let userAccessService: UserAccessService;
|
||||
@@ -29,8 +30,8 @@ describe('UserAccessService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [HttpClientTestingModule],
|
||||
providers: [UserAccessService]
|
||||
imports: [HttpClientTestingModule, AuthModule.forRoot({ useHash: true })],
|
||||
providers: [{ provide: JWT_STORAGE_SERVICE, useClass: StorageService }, UserAccessService]
|
||||
});
|
||||
userAccessService = TestBed.inject(UserAccessService);
|
||||
jwtHelperService = TestBed.inject(JwtHelperService);
|
||||
|
@@ -21,7 +21,6 @@ import { TranslationService } from './translation.service';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { CoreModule } from '../core.module';
|
||||
import { AuthModule } from '../auth/oidc/auth.module';
|
||||
import { StorageService } from '../common';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
|
Reference in New Issue
Block a user