mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
115016: Fixed tests for 114858
This commit is contained in:
@@ -1,20 +1,18 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { UrlTree, Router } from '@angular/router';
|
||||
import { Router, UrlTree } from '@angular/router';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { AuthService } from 'src/app/core/auth/auth.service';
|
||||
import { AuthorizationDataService } from 'src/app/core/data/feature-authorization/authorization-data.service';
|
||||
import { FeatureID } from 'src/app/core/data/feature-authorization/feature-id';
|
||||
import {
|
||||
Store,
|
||||
} from '@ngrx/store';
|
||||
import { Store, } from '@ngrx/store';
|
||||
|
||||
import { itemPageEditAuthorizationsGuard } from './item-page-edit-authorizations.guard';
|
||||
import { APP_DATA_SERVICES_MAP } from '../../../config/app-config.interface';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { getMockTranslateService } from '../../shared/mocks/translate.service.mock';
|
||||
import {
|
||||
dsoPageSingleFeatureGuard
|
||||
} from '../../core/data/feature-authorization/feature-authorization-guard/dso-page-single-feature.guard';
|
||||
import { ItemDataService } from '../../core/data/item-data.service';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
||||
import { Item } from '../../core/shared/item.model';
|
||||
|
||||
describe('itemPageEditAuthorizationsGuard', () => {
|
||||
let authorizationService: AuthorizationDataService;
|
||||
@@ -23,6 +21,10 @@ describe('itemPageEditAuthorizationsGuard', () => {
|
||||
let route;
|
||||
let parentRoute;
|
||||
let store: Store;
|
||||
let itemService: ItemDataService;
|
||||
let item: Item;
|
||||
let uuid = '1234-abcdef-54321-fedcba';
|
||||
let itemSelfLink = 'test.url/1234-abcdef-54321-fedcba';
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -35,6 +37,7 @@ describe('itemPageEditAuthorizationsGuard', () => {
|
||||
});
|
||||
router = jasmine.createSpyObj('router', {
|
||||
parseUrl: {},
|
||||
navigateByUrl: undefined,
|
||||
});
|
||||
authService = jasmine.createSpyObj('authService', {
|
||||
isAuthenticated: observableOf(true),
|
||||
@@ -46,10 +49,13 @@ describe('itemPageEditAuthorizationsGuard', () => {
|
||||
},
|
||||
};
|
||||
route = {
|
||||
params: {
|
||||
},
|
||||
params: {},
|
||||
parent: parentRoute,
|
||||
};
|
||||
item = new Item();
|
||||
item.uuid = uuid;
|
||||
item._links = { self: { href: itemSelfLink } } as any;
|
||||
itemService = jasmine.createSpyObj('itemService', { findById: createSuccessfulRemoteDataObject$(item) })
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
providers: [
|
||||
@@ -59,6 +65,7 @@ describe('itemPageEditAuthorizationsGuard', () => {
|
||||
{ provide: Store, useValue: store },
|
||||
{ provide: APP_DATA_SERVICES_MAP, useValue: {} },
|
||||
{ provide: TranslateService, useValue: getMockTranslateService() },
|
||||
{ provide: ItemDataService, useValue: itemService },
|
||||
],
|
||||
});
|
||||
});
|
||||
@@ -73,8 +80,8 @@ describe('itemPageEditAuthorizationsGuard', () => {
|
||||
console.log('result inside subscribe:', result);
|
||||
expect(authorizationService.isAuthorized).toHaveBeenCalledWith(
|
||||
FeatureID.CanManagePolicies,
|
||||
'fake-object-url',
|
||||
'fake-eperson-uuid',
|
||||
itemSelfLink, // This value is retrieved from the itemDataService.findById's return item's self link
|
||||
undefined, // dsoPageSingleFeatureGuard never provides a function to retrieve a person ID
|
||||
);
|
||||
done();
|
||||
});
|
||||
|
Reference in New Issue
Block a user