11import { TestBed } from '@angular/core/testing' ;
2+ import { APP_CONFIG } from '@dspace/config/app-config.interface' ;
23import { AuthorizationDataService } from '@dspace/core/data/feature-authorization/authorization-data.service' ;
34import { Collection } from '@dspace/core/shared/collection.model' ;
45import { COLLECTION } from '@dspace/core/shared/collection.resource-type' ;
5- import { of } from 'rxjs' ;
6+ import {
7+ Observable ,
8+ of ,
9+ } from 'rxjs' ;
610
11+ import { environment } from '../../../../environments/environment' ;
712import { MenuItemType } from '../menu-item-type.model' ;
813import { PartialMenuSection } from '../menu-provider.model' ;
914import { SubmitNewItemMenuProvider } from './submit-new-item.menu' ;
@@ -34,7 +39,7 @@ describe('SubmitNewItemMenuProvider', () => {
3439 } ) ;
3540
3641
37- let authorizationService ;
42+ let authorizationService : { isAuthorized : Observable < boolean > ; } ;
3843
3944 beforeEach ( ( ) => {
4045
@@ -46,6 +51,7 @@ describe('SubmitNewItemMenuProvider', () => {
4651 providers : [
4752 SubmitNewItemMenuProvider ,
4853 { provide : AuthorizationDataService , useValue : authorizationService } ,
54+ { provide : APP_CONFIG , useValue : environment } ,
4955 ] ,
5056 } ) ;
5157 provider = TestBed . inject ( SubmitNewItemMenuProvider ) ;
@@ -62,6 +68,12 @@ describe('SubmitNewItemMenuProvider', () => {
6268 done ( ) ;
6369 } ) ;
6470 } ) ;
65- } ) ;
6671
72+ it ( 'should set visibility depending on authorization and collection.showSubmitButton' , done => {
73+ provider . getSectionsForContext ( dso ) . subscribe ( ( sections ) => {
74+ expect ( sections [ 0 ] . visible ) . toEqual ( authorizationService . isAuthorized && ! environment . collection . showSubmitButton ) ;
75+ done ( ) ;
76+ } ) ;
77+ } ) ;
78+ } ) ;
6779} ) ;
0 commit comments