mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
117648: Add tests for basic MenuProviders
This commit is contained in:
95
src/app/shared/menu/providers/access-control.menu.spec.ts
Normal file
95
src/app/shared/menu/providers/access-control.menu.spec.ts
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { MenuItemType } from '../menu-item-type.model';
|
||||||
|
import { MenuSubSection, MenuTopSection } from './expandable-menu-provider';
|
||||||
|
import { AuthorizationDataServiceStub } from '../../testing/authorization-service.stub';
|
||||||
|
import { of as observableOf } from 'rxjs';
|
||||||
|
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
||||||
|
import { AccessControlMenuProvider } from './access-control.menu';
|
||||||
|
import { ScriptDataService } from '../../../core/data/processes/script-data.service';
|
||||||
|
import { ScriptServiceStub } from '../../testing/script-service.stub';
|
||||||
|
|
||||||
|
const expectedTopSection: MenuTopSection = {
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.TEXT,
|
||||||
|
text: 'menu.section.access_control',
|
||||||
|
},
|
||||||
|
icon: 'key'
|
||||||
|
};
|
||||||
|
|
||||||
|
const expectedSubSections: MenuSubSection[] = [
|
||||||
|
{
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.LINK,
|
||||||
|
text: 'menu.section.access_control_people',
|
||||||
|
link: '/access-control/epeople',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
visible: false,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.LINK,
|
||||||
|
text: 'menu.section.access_control_groups',
|
||||||
|
link: '/access-control/groups',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.LINK,
|
||||||
|
text: 'menu.section.access_control_bulk',
|
||||||
|
link: '/access-control/bulk-access',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
describe('AccessControlMenuProvider', () => {
|
||||||
|
let provider: AccessControlMenuProvider;
|
||||||
|
let authorizationServiceStub = new AuthorizationDataServiceStub();
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(authorizationServiceStub, 'isAuthorized').and.callFake((id: FeatureID) => {
|
||||||
|
if (id === FeatureID.CanManageGroups) {
|
||||||
|
return observableOf(false);
|
||||||
|
} else {
|
||||||
|
return observableOf(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [
|
||||||
|
AccessControlMenuProvider,
|
||||||
|
{ provide: AuthorizationDataService, useValue: authorizationServiceStub },
|
||||||
|
{ provide: ScriptDataService, useClass: ScriptServiceStub },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
provider = TestBed.inject(AccessControlMenuProvider);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(provider).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getTopSection should return expected menu section', (done) => {
|
||||||
|
provider.getTopSection().subscribe((section) => {
|
||||||
|
expect(section).toEqual(expectedTopSection);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getSubSections should return expected menu sections', (done) => {
|
||||||
|
provider.getSubSections().subscribe((sections) => {
|
||||||
|
expect(sections).toEqual(expectedSubSections);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
57
src/app/shared/menu/providers/admin-search.menu.spec.ts
Normal file
57
src/app/shared/menu/providers/admin-search.menu.spec.ts
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { PartialMenuSection } from '../menu-provider';
|
||||||
|
import { MenuItemType } from '../menu-item-type.model';
|
||||||
|
import { AdminSearchMenuProvider } from './admin-search.menu';
|
||||||
|
import { AuthorizationDataServiceStub } from '../../testing/authorization-service.stub';
|
||||||
|
import { of as observableOf } from 'rxjs';
|
||||||
|
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
|
||||||
|
const expectedSections: PartialMenuSection[] = [
|
||||||
|
{
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.LINK,
|
||||||
|
text: 'menu.section.admin_search',
|
||||||
|
link: '/admin/search',
|
||||||
|
},
|
||||||
|
icon: 'search',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
describe('AdminSearchMenuProvider', () => {
|
||||||
|
let provider: AdminSearchMenuProvider;
|
||||||
|
let authorizationServiceStub = new AuthorizationDataServiceStub();
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(authorizationServiceStub, 'isAuthorized').and.returnValue(
|
||||||
|
observableOf(true)
|
||||||
|
);
|
||||||
|
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [
|
||||||
|
AdminSearchMenuProvider,
|
||||||
|
{ provide: AuthorizationDataService, useValue: authorizationServiceStub },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
provider = TestBed.inject(AdminSearchMenuProvider);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(provider).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getSections should return expected menu sections', (done) => {
|
||||||
|
provider.getSections().subscribe((sections) => {
|
||||||
|
expect(sections).toEqual(expectedSections);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
87
src/app/shared/menu/providers/browse.menu.spec.ts
Normal file
87
src/app/shared/menu/providers/browse.menu.spec.ts
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { BrowseMenuProvider } from './browse.menu';
|
||||||
|
import { MenuItemType } from '../menu-item-type.model';
|
||||||
|
import { MenuSubSection, MenuTopSection } from './expandable-menu-provider';
|
||||||
|
import { BrowseService } from '../../../core/browse/browse.service';
|
||||||
|
import { BrowseServiceStub } from '../../testing/browse-service.stub';
|
||||||
|
import { ObjectCacheService } from '../../../core/cache/object-cache.service';
|
||||||
|
import { getMockObjectCacheService } from '../../mocks/object-cache.service.mock';
|
||||||
|
import { BrowseDefinition } from '../../../core/shared/browse-definition.model';
|
||||||
|
import { createSuccessfulRemoteDataObject$ } from '../../remote-data.utils';
|
||||||
|
import { createPaginatedList } from '../../testing/utils.test';
|
||||||
|
|
||||||
|
const expectedTopSection: MenuTopSection = {
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.TEXT,
|
||||||
|
text: 'menu.section.browse_global',
|
||||||
|
},
|
||||||
|
icon: 'globe',
|
||||||
|
};
|
||||||
|
|
||||||
|
const expectedSubSections: MenuSubSection[] = [
|
||||||
|
{
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.LINK,
|
||||||
|
text: 'menu.section.browse_global_by_author',
|
||||||
|
link: '/browse/author',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.LINK,
|
||||||
|
text: 'menu.section.browse_global_by_subject',
|
||||||
|
link: '/browse/subject',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
describe('BrowseMenuProvider', () => {
|
||||||
|
let provider: BrowseMenuProvider;
|
||||||
|
let browseServiceStub = new BrowseServiceStub();
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(browseServiceStub, 'getBrowseDefinitions').and.returnValue(
|
||||||
|
createSuccessfulRemoteDataObject$(createPaginatedList([
|
||||||
|
{ id: 'author' } as BrowseDefinition,
|
||||||
|
{ id: 'subject' } as BrowseDefinition,
|
||||||
|
]))
|
||||||
|
);
|
||||||
|
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [
|
||||||
|
BrowseMenuProvider,
|
||||||
|
{ provide: BrowseService, useValue: browseServiceStub },
|
||||||
|
{ provide: ObjectCacheService, useValue: getMockObjectCacheService() },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
provider = TestBed.inject(BrowseMenuProvider);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(provider).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getTopSection should return expected menu section', (done) => {
|
||||||
|
provider.getTopSection().subscribe((section) => {
|
||||||
|
expect(section).toEqual(expectedTopSection);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getSubSections should return expected menu sections', (done) => {
|
||||||
|
provider.getSubSections().subscribe((sections) => {
|
||||||
|
expect(sections).toEqual(expectedSubSections);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
48
src/app/shared/menu/providers/community-list.menu.spec.ts
Normal file
48
src/app/shared/menu/providers/community-list.menu.spec.ts
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { CommunityListMenuProvider } from './community-list.menu';
|
||||||
|
import { PartialMenuSection } from '../menu-provider';
|
||||||
|
import { MenuItemType } from '../menu-item-type.model';
|
||||||
|
|
||||||
|
const expectedSections: PartialMenuSection[] = [
|
||||||
|
{
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.LINK,
|
||||||
|
text: `menu.section.browse_global_communities_and_collections`,
|
||||||
|
link: `/community-list`,
|
||||||
|
},
|
||||||
|
icon: 'diagram-project'
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
describe('CommunityListMenuProvider', () => {
|
||||||
|
let provider: CommunityListMenuProvider;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [
|
||||||
|
CommunityListMenuProvider,
|
||||||
|
],
|
||||||
|
});
|
||||||
|
provider = TestBed.inject(CommunityListMenuProvider);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(provider).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getSections should return expected menu sections', (done) => {
|
||||||
|
provider.getSections().subscribe((sections) => {
|
||||||
|
expect(sections).toEqual(expectedSections);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
57
src/app/shared/menu/providers/curation.menu.spec.ts
Normal file
57
src/app/shared/menu/providers/curation.menu.spec.ts
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { PartialMenuSection } from '../menu-provider';
|
||||||
|
import { MenuItemType } from '../menu-item-type.model';
|
||||||
|
import { AuthorizationDataServiceStub } from '../../testing/authorization-service.stub';
|
||||||
|
import { of as observableOf } from 'rxjs';
|
||||||
|
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
import { CurationMenuProvider } from './curation.menu';
|
||||||
|
|
||||||
|
const expectedSections: PartialMenuSection[] = [
|
||||||
|
{
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.LINK,
|
||||||
|
text: 'menu.section.curation_task',
|
||||||
|
link: 'admin/curation-tasks',
|
||||||
|
},
|
||||||
|
icon: 'filter',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
describe('CurationMenuProvider', () => {
|
||||||
|
let provider: CurationMenuProvider;
|
||||||
|
let authorizationServiceStub = new AuthorizationDataServiceStub();
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(authorizationServiceStub, 'isAuthorized').and.returnValue(
|
||||||
|
observableOf(true)
|
||||||
|
);
|
||||||
|
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [
|
||||||
|
CurationMenuProvider,
|
||||||
|
{ provide: AuthorizationDataService, useValue: authorizationServiceStub },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
provider = TestBed.inject(CurationMenuProvider);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(provider).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getSections should return expected menu sections', (done) => {
|
||||||
|
provider.getSections().subscribe((sections) => {
|
||||||
|
expect(sections).toEqual(expectedSections);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
92
src/app/shared/menu/providers/edit.menu.spec.ts
Normal file
92
src/app/shared/menu/providers/edit.menu.spec.ts
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { MenuItemType } from '../menu-item-type.model';
|
||||||
|
import { MenuSubSection, MenuTopSection } from './expandable-menu-provider';
|
||||||
|
import { AuthorizationDataServiceStub } from '../../testing/authorization-service.stub';
|
||||||
|
import { of as observableOf } from 'rxjs';
|
||||||
|
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
||||||
|
import { EditMenuProvider } from './edit.menu';
|
||||||
|
|
||||||
|
const expectedTopSection: MenuTopSection = {
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.TEXT,
|
||||||
|
text: 'menu.section.edit'
|
||||||
|
},
|
||||||
|
icon: 'pencil',
|
||||||
|
};
|
||||||
|
|
||||||
|
const expectedSubSections: MenuSubSection[] = [
|
||||||
|
{
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.ONCLICK,
|
||||||
|
text: 'menu.section.edit_community',
|
||||||
|
function: jasmine.any(Function) as any,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
visible: false,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.ONCLICK,
|
||||||
|
text: 'menu.section.edit_collection',
|
||||||
|
function: jasmine.any(Function) as any,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.ONCLICK,
|
||||||
|
text: 'menu.section.edit_item',
|
||||||
|
function: jasmine.any(Function) as any,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
describe('EditMenuProvider', () => {
|
||||||
|
let provider: EditMenuProvider;
|
||||||
|
let authorizationServiceStub = new AuthorizationDataServiceStub();
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(authorizationServiceStub, 'isAuthorized').and.callFake((id: FeatureID) => {
|
||||||
|
if (id === FeatureID.IsCollectionAdmin) {
|
||||||
|
return observableOf(false);
|
||||||
|
} else {
|
||||||
|
return observableOf(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [
|
||||||
|
EditMenuProvider,
|
||||||
|
{ provide: AuthorizationDataService, useValue: authorizationServiceStub },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
provider = TestBed.inject(EditMenuProvider);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(provider).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getTopSection should return expected menu section', (done) => {
|
||||||
|
provider.getTopSection().subscribe((section) => {
|
||||||
|
expect(section).toEqual(expectedTopSection);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getSubSections should return expected menu sections', (done) => {
|
||||||
|
provider.getSubSections().subscribe((sections) => {
|
||||||
|
expect(sections).toEqual(expectedSubSections);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
85
src/app/shared/menu/providers/export.menu.spec.ts
Normal file
85
src/app/shared/menu/providers/export.menu.spec.ts
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { MenuItemType } from '../menu-item-type.model';
|
||||||
|
import { MenuSubSection, MenuTopSection } from './expandable-menu-provider';
|
||||||
|
import { AuthorizationDataServiceStub } from '../../testing/authorization-service.stub';
|
||||||
|
import { of as observableOf } from 'rxjs';
|
||||||
|
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
import { ScriptDataService } from '../../../core/data/processes/script-data.service';
|
||||||
|
import { ScriptServiceStub } from '../../testing/script-service.stub';
|
||||||
|
import { ExportMenuProvider } from './export.menu';
|
||||||
|
|
||||||
|
const expectedTopSection: MenuTopSection = {
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.TEXT,
|
||||||
|
text: 'menu.section.export',
|
||||||
|
},
|
||||||
|
icon: 'file-export',
|
||||||
|
shouldPersistOnRouteChange: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
const expectedSubSections: MenuSubSection[] = [
|
||||||
|
{
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.ONCLICK,
|
||||||
|
text: 'menu.section.export_metadata',
|
||||||
|
function: jasmine.any(Function) as any,
|
||||||
|
},
|
||||||
|
shouldPersistOnRouteChange: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.ONCLICK,
|
||||||
|
text: 'menu.section.export_batch',
|
||||||
|
function: jasmine.any(Function) as any,
|
||||||
|
},
|
||||||
|
shouldPersistOnRouteChange: true,
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
describe('ExportMenuProvider', () => {
|
||||||
|
let provider: ExportMenuProvider;
|
||||||
|
let authorizationServiceStub = new AuthorizationDataServiceStub();
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(authorizationServiceStub, 'isAuthorized').and.returnValue(
|
||||||
|
observableOf(true)
|
||||||
|
);
|
||||||
|
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [
|
||||||
|
ExportMenuProvider,
|
||||||
|
{ provide: AuthorizationDataService, useValue: authorizationServiceStub },
|
||||||
|
{ provide: ScriptDataService, useClass: ScriptServiceStub },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
provider = TestBed.inject(ExportMenuProvider);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(provider).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getTopSection should return expected menu section', (done) => {
|
||||||
|
provider.getTopSection().subscribe((section) => {
|
||||||
|
expect(section).toEqual(expectedTopSection);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getSubSections should return expected menu sections', (done) => {
|
||||||
|
provider.getSubSections().subscribe((sections) => {
|
||||||
|
expect(sections).toEqual(expectedSubSections);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
57
src/app/shared/menu/providers/health.menu.spec.ts
Normal file
57
src/app/shared/menu/providers/health.menu.spec.ts
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { PartialMenuSection } from '../menu-provider';
|
||||||
|
import { MenuItemType } from '../menu-item-type.model';
|
||||||
|
import { AuthorizationDataServiceStub } from '../../testing/authorization-service.stub';
|
||||||
|
import { of as observableOf } from 'rxjs';
|
||||||
|
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
import { HealthMenuProvider } from './health.menu';
|
||||||
|
|
||||||
|
const expectedSections: PartialMenuSection[] = [
|
||||||
|
{
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.LINK,
|
||||||
|
text: 'menu.section.health',
|
||||||
|
link: '/health',
|
||||||
|
},
|
||||||
|
icon: 'heartbeat',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
describe('HealthMenuProvider', () => {
|
||||||
|
let provider: HealthMenuProvider;
|
||||||
|
let authorizationServiceStub = new AuthorizationDataServiceStub();
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(authorizationServiceStub, 'isAuthorized').and.returnValue(
|
||||||
|
observableOf(true)
|
||||||
|
);
|
||||||
|
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [
|
||||||
|
HealthMenuProvider,
|
||||||
|
{ provide: AuthorizationDataService, useValue: authorizationServiceStub },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
provider = TestBed.inject(HealthMenuProvider);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(provider).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getSections should return expected menu sections', (done) => {
|
||||||
|
provider.getSections().subscribe((sections) => {
|
||||||
|
expect(sections).toEqual(expectedSections);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
83
src/app/shared/menu/providers/import.menu.spec.ts
Normal file
83
src/app/shared/menu/providers/import.menu.spec.ts
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { MenuItemType } from '../menu-item-type.model';
|
||||||
|
import { MenuSubSection, MenuTopSection } from './expandable-menu-provider';
|
||||||
|
import { AuthorizationDataServiceStub } from '../../testing/authorization-service.stub';
|
||||||
|
import { of as observableOf } from 'rxjs';
|
||||||
|
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
import { ImportMenuProvider } from './import.menu';
|
||||||
|
import { ScriptDataService } from '../../../core/data/processes/script-data.service';
|
||||||
|
import { ScriptServiceStub } from '../../testing/script-service.stub';
|
||||||
|
|
||||||
|
const expectedTopSection: MenuTopSection = {
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.TEXT,
|
||||||
|
text: 'menu.section.import',
|
||||||
|
},
|
||||||
|
icon: 'file-import',
|
||||||
|
shouldPersistOnRouteChange: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
const expectedSubSections: MenuSubSection[] = [
|
||||||
|
{
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.LINK,
|
||||||
|
text: 'menu.section.import_metadata',
|
||||||
|
link: '/admin/metadata-import',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.LINK,
|
||||||
|
text: 'menu.section.import_batch',
|
||||||
|
link: '/admin/batch-import',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
describe('ImportMenuProvider', () => {
|
||||||
|
let provider: ImportMenuProvider;
|
||||||
|
let authorizationServiceStub = new AuthorizationDataServiceStub();
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(authorizationServiceStub, 'isAuthorized').and.returnValue(
|
||||||
|
observableOf(true)
|
||||||
|
);
|
||||||
|
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [
|
||||||
|
ImportMenuProvider,
|
||||||
|
{ provide: AuthorizationDataService, useValue: authorizationServiceStub },
|
||||||
|
{ provide: ScriptDataService, useClass: ScriptServiceStub },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
provider = TestBed.inject(ImportMenuProvider);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(provider).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getTopSection should return expected menu section', (done) => {
|
||||||
|
provider.getTopSection().subscribe((section) => {
|
||||||
|
expect(section).toEqual(expectedTopSection);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getSubSections should return expected menu sections', (done) => {
|
||||||
|
provider.getSubSections().subscribe((sections) => {
|
||||||
|
expect(sections).toEqual(expectedSubSections);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
100
src/app/shared/menu/providers/new.menu.spec.ts
Normal file
100
src/app/shared/menu/providers/new.menu.spec.ts
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { MenuItemType } from '../menu-item-type.model';
|
||||||
|
import { MenuSubSection, MenuTopSection } from './expandable-menu-provider';
|
||||||
|
import { NewMenuProvider } from './new.menu';
|
||||||
|
import { AuthorizationDataServiceStub } from '../../testing/authorization-service.stub';
|
||||||
|
import { of as observableOf } from 'rxjs';
|
||||||
|
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
||||||
|
|
||||||
|
const expectedTopSection: MenuTopSection = {
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.TEXT,
|
||||||
|
text: 'menu.section.new'
|
||||||
|
},
|
||||||
|
icon: 'plus',
|
||||||
|
};
|
||||||
|
|
||||||
|
const expectedSubSections: MenuSubSection[] = [
|
||||||
|
{
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.ONCLICK,
|
||||||
|
text: 'menu.section.new_community',
|
||||||
|
function: jasmine.any(Function) as any,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
visible: false,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.ONCLICK,
|
||||||
|
text: 'menu.section.new_collection',
|
||||||
|
function: jasmine.any(Function) as any,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.ONCLICK,
|
||||||
|
text: 'menu.section.new_item',
|
||||||
|
function: jasmine.any(Function) as any,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.LINK,
|
||||||
|
text: 'menu.section.new_process',
|
||||||
|
link: '/processes/new'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
describe('NewMenuProvider', () => {
|
||||||
|
let provider: NewMenuProvider;
|
||||||
|
let authorizationServiceStub = new AuthorizationDataServiceStub();
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(authorizationServiceStub, 'isAuthorized').and.callFake((id: FeatureID) => {
|
||||||
|
if (id === FeatureID.IsCollectionAdmin) {
|
||||||
|
return observableOf(false);
|
||||||
|
} else {
|
||||||
|
return observableOf(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [
|
||||||
|
NewMenuProvider,
|
||||||
|
{ provide: AuthorizationDataService, useValue: authorizationServiceStub },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
provider = TestBed.inject(NewMenuProvider);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(provider).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getTopSection should return expected menu section', (done) => {
|
||||||
|
provider.getTopSection().subscribe((section) => {
|
||||||
|
expect(section).toEqual(expectedTopSection);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getSubSections should return expected menu sections', (done) => {
|
||||||
|
provider.getSubSections().subscribe((sections) => {
|
||||||
|
expect(sections).toEqual(expectedSubSections);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@@ -57,7 +57,7 @@ export class NewMenuProvider extends AbstractExpandableMenuProvider {
|
|||||||
]).pipe(map(([isCollectionAdmin, isCommunityAdmin, isSiteAdmin, canSubmit]) => {
|
]).pipe(map(([isCollectionAdmin, isCommunityAdmin, isSiteAdmin, canSubmit]) => {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
visible: isCollectionAdmin,
|
visible: isCommunityAdmin,
|
||||||
model: {
|
model: {
|
||||||
type: MenuItemType.ONCLICK,
|
type: MenuItemType.ONCLICK,
|
||||||
text: 'menu.section.new_community',
|
text: 'menu.section.new_community',
|
||||||
@@ -67,7 +67,7 @@ export class NewMenuProvider extends AbstractExpandableMenuProvider {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
visible: isCommunityAdmin,
|
visible: isCollectionAdmin,
|
||||||
model: {
|
model: {
|
||||||
type: MenuItemType.ONCLICK,
|
type: MenuItemType.ONCLICK,
|
||||||
text: 'menu.section.new_collection',
|
text: 'menu.section.new_collection',
|
||||||
|
57
src/app/shared/menu/providers/processes.menu.spec.ts
Normal file
57
src/app/shared/menu/providers/processes.menu.spec.ts
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { PartialMenuSection } from '../menu-provider';
|
||||||
|
import { MenuItemType } from '../menu-item-type.model';
|
||||||
|
import { AuthorizationDataServiceStub } from '../../testing/authorization-service.stub';
|
||||||
|
import { of as observableOf } from 'rxjs';
|
||||||
|
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
import { ProcessesMenuProvider } from './processes.menu';
|
||||||
|
|
||||||
|
const expectedSections: PartialMenuSection[] = [
|
||||||
|
{
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.LINK,
|
||||||
|
text: 'menu.section.processes',
|
||||||
|
link: '/processes',
|
||||||
|
},
|
||||||
|
icon: 'terminal',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
describe('ProcessesMenuProvider', () => {
|
||||||
|
let provider: ProcessesMenuProvider;
|
||||||
|
let authorizationServiceStub = new AuthorizationDataServiceStub();
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(authorizationServiceStub, 'isAuthorized').and.returnValue(
|
||||||
|
observableOf(true)
|
||||||
|
);
|
||||||
|
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [
|
||||||
|
ProcessesMenuProvider,
|
||||||
|
{ provide: AuthorizationDataService, useValue: authorizationServiceStub },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
provider = TestBed.inject(ProcessesMenuProvider);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(provider).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getSections should return expected menu sections', (done) => {
|
||||||
|
provider.getSections().subscribe((sections) => {
|
||||||
|
expect(sections).toEqual(expectedSections);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
82
src/app/shared/menu/providers/registries.menu.spec.ts
Normal file
82
src/app/shared/menu/providers/registries.menu.spec.ts
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { MenuItemType } from '../menu-item-type.model';
|
||||||
|
import { MenuSubSection, MenuTopSection } from './expandable-menu-provider';
|
||||||
|
import { AuthorizationDataServiceStub } from '../../testing/authorization-service.stub';
|
||||||
|
import { of as observableOf } from 'rxjs';
|
||||||
|
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
import { ScriptDataService } from '../../../core/data/processes/script-data.service';
|
||||||
|
import { ScriptServiceStub } from '../../testing/script-service.stub';
|
||||||
|
import { RegistriesMenuProvider } from './registries.menu';
|
||||||
|
|
||||||
|
const expectedTopSection: MenuTopSection = {
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.TEXT,
|
||||||
|
text: 'menu.section.registries',
|
||||||
|
},
|
||||||
|
icon: 'list',
|
||||||
|
};
|
||||||
|
|
||||||
|
const expectedSubSections: MenuSubSection[] = [
|
||||||
|
{
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.LINK,
|
||||||
|
text: 'menu.section.registries_metadata',
|
||||||
|
link: 'admin/registries/metadata',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.LINK,
|
||||||
|
text: 'menu.section.registries_format',
|
||||||
|
link: 'admin/registries/bitstream-formats',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
describe('RegistriesMenuProvider', () => {
|
||||||
|
let provider: RegistriesMenuProvider;
|
||||||
|
let authorizationServiceStub = new AuthorizationDataServiceStub();
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(authorizationServiceStub, 'isAuthorized').and.returnValue(
|
||||||
|
observableOf(true)
|
||||||
|
);
|
||||||
|
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [
|
||||||
|
RegistriesMenuProvider,
|
||||||
|
{ provide: AuthorizationDataService, useValue: authorizationServiceStub },
|
||||||
|
{ provide: ScriptDataService, useClass: ScriptServiceStub },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
provider = TestBed.inject(RegistriesMenuProvider);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(provider).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getTopSection should return expected menu section', (done) => {
|
||||||
|
provider.getTopSection().subscribe((section) => {
|
||||||
|
expect(section).toEqual(expectedTopSection);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getSubSections should return expected menu sections', (done) => {
|
||||||
|
provider.getSubSections().subscribe((sections) => {
|
||||||
|
expect(sections).toEqual(expectedSubSections);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
57
src/app/shared/menu/providers/system-wide-alert.menu.spec.ts
Normal file
57
src/app/shared/menu/providers/system-wide-alert.menu.spec.ts
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { PartialMenuSection } from '../menu-provider';
|
||||||
|
import { MenuItemType } from '../menu-item-type.model';
|
||||||
|
import { AuthorizationDataServiceStub } from '../../testing/authorization-service.stub';
|
||||||
|
import { of as observableOf } from 'rxjs';
|
||||||
|
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
import { SystemWideAlertMenuProvider } from './system-wide-alert.menu';
|
||||||
|
|
||||||
|
const expectedSections: PartialMenuSection[] = [
|
||||||
|
{
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.LINK,
|
||||||
|
text: 'menu.section.system-wide-alert',
|
||||||
|
link: '/admin/system-wide-alert',
|
||||||
|
},
|
||||||
|
icon: 'exclamation-circle',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
describe('SystemWideAlertMenuProvider', () => {
|
||||||
|
let provider: SystemWideAlertMenuProvider;
|
||||||
|
let authorizationServiceStub = new AuthorizationDataServiceStub();
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(authorizationServiceStub, 'isAuthorized').and.returnValue(
|
||||||
|
observableOf(true)
|
||||||
|
);
|
||||||
|
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [
|
||||||
|
SystemWideAlertMenuProvider,
|
||||||
|
{ provide: AuthorizationDataService, useValue: authorizationServiceStub },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
provider = TestBed.inject(SystemWideAlertMenuProvider);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(provider).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getSections should return expected menu sections', (done) => {
|
||||||
|
provider.getSections().subscribe((sections) => {
|
||||||
|
expect(sections).toEqual(expectedSections);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
57
src/app/shared/menu/providers/workflow.menu.spec.ts
Normal file
57
src/app/shared/menu/providers/workflow.menu.spec.ts
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { PartialMenuSection } from '../menu-provider';
|
||||||
|
import { MenuItemType } from '../menu-item-type.model';
|
||||||
|
import { AuthorizationDataServiceStub } from '../../testing/authorization-service.stub';
|
||||||
|
import { of as observableOf } from 'rxjs';
|
||||||
|
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
import { WorkflowMenuProvider } from './workflow.menu';
|
||||||
|
|
||||||
|
const expectedSections: PartialMenuSection[] = [
|
||||||
|
{
|
||||||
|
visible: true,
|
||||||
|
model: {
|
||||||
|
type: MenuItemType.LINK,
|
||||||
|
text: 'menu.section.workflow',
|
||||||
|
link: '/admin/workflow',
|
||||||
|
},
|
||||||
|
icon: 'user-check',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
describe('WorkflowMenuProvider', () => {
|
||||||
|
let provider: WorkflowMenuProvider;
|
||||||
|
let authorizationServiceStub = new AuthorizationDataServiceStub();
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(authorizationServiceStub, 'isAuthorized').and.returnValue(
|
||||||
|
observableOf(true)
|
||||||
|
);
|
||||||
|
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [
|
||||||
|
WorkflowMenuProvider,
|
||||||
|
{ provide: AuthorizationDataService, useValue: authorizationServiceStub },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
provider = TestBed.inject(WorkflowMenuProvider);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(provider).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getSections should return expected menu sections', (done) => {
|
||||||
|
provider.getSections().subscribe((sections) => {
|
||||||
|
expect(sections).toEqual(expectedSections);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
22
src/app/shared/testing/browse-service.stub.ts
Normal file
22
src/app/shared/testing/browse-service.stub.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
import { createSuccessfulRemoteDataObject$ } from '../remote-data.utils';
|
||||||
|
import { createPaginatedList } from './utils.test';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { RemoteData } from '../../core/data/remote-data';
|
||||||
|
import { PaginatedList } from '../../core/data/paginated-list.model';
|
||||||
|
import { BrowseDefinition } from '../../core/shared/browse-definition.model';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stub class of {@link BrowseService}.
|
||||||
|
*/
|
||||||
|
export class BrowseServiceStub {
|
||||||
|
getBrowseDefinitions(): Observable<RemoteData<PaginatedList<BrowseDefinition>>> {
|
||||||
|
return createSuccessfulRemoteDataObject$(createPaginatedList([]));
|
||||||
|
}
|
||||||
|
}
|
18
src/app/shared/testing/script-service.stub.ts
Normal file
18
src/app/shared/testing/script-service.stub.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Observable, of as observableOf } from 'rxjs';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stub class of {@link ScriptDataService}.
|
||||||
|
*/
|
||||||
|
export class ScriptServiceStub {
|
||||||
|
scriptWithNameExistsAndCanExecute(scriptName: string): Observable<boolean> {
|
||||||
|
return observableOf(true);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user