@@ -8,11 +8,16 @@ import {
88 ActivatedRoute ,
99 RouterLink ,
1010} from '@angular/router' ;
11+ import { Store } from '@ngrx/store' ;
1112import { TranslateModule } from '@ngx-translate/core' ;
1213import {
1314 cold ,
1415 getTestScheduler ,
1516} from 'jasmine-marbles' ;
17+ import {
18+ APP_CONFIG ,
19+ APP_DATA_SERVICES_MAP ,
20+ } from 'src/config/app-config.interface' ;
1621
1722import { getBitstreamModuleRoute } from '../../app-routing-paths' ;
1823import { ConfigurationDataService } from '../../core/data/configuration-data.service' ;
@@ -21,6 +26,7 @@ import { FeatureID } from '../../core/data/feature-authorization/feature-id';
2126import { Bitstream } from '../../core/shared/bitstream.model' ;
2227import { ConfigurationProperty } from '../../core/shared/configuration-property.model' ;
2328import { Item } from '../../core/shared/item.model' ;
29+ import { ItemRequest } from '../../core/shared/item-request.model' ;
2430import { URLCombiner } from '../../core/url-combiner/url-combiner' ;
2531import { getItemModuleRoute } from '../../item-page/item-page-routing-paths' ;
2632import { createSuccessfulRemoteDataObject$ } from '../remote-data.utils' ;
@@ -38,6 +44,24 @@ describe('FileDownloadLinkComponent', () => {
3844 let bitstream : Bitstream ;
3945 let item : Item ;
4046 let configurationDataService : ConfigurationDataService ;
47+ let storeMock : any ;
48+
49+ const mockAppConfig = {
50+ item : {
51+ bitstream : {
52+ openDownloadLinksInNewTab : true ,
53+ } ,
54+ } ,
55+ } ;
56+
57+ const itemRequestStub = Object . assign ( new ItemRequest ( ) , {
58+ token : 'item-request-token' ,
59+ requestName : 'requester name' ,
60+ accessToken : 'abc123' ,
61+ acceptRequest : true ,
62+ accessExpired : false ,
63+ allfiles : true ,
64+ } ) ;
4165
4266 function init ( ) {
4367 authorizationService = jasmine . createSpyObj ( 'authorizationService' , {
@@ -72,6 +96,9 @@ describe('FileDownloadLinkComponent', () => {
7296 providers : [
7397 RouterLinkDirectiveStub ,
7498 { provide : AuthorizationDataService , useValue : authorizationService } ,
99+ { provide : Store , useValue : storeMock } ,
100+ { provide : APP_DATA_SERVICES_MAP , useValue : { } } ,
101+ { provide : APP_CONFIG , useValue : mockAppConfig } ,
75102 { provide : ConfigurationDataService , useValue : configurationDataService } ,
76103 { provide : ActivatedRoute , useValue : new ActivatedRouteStub ( ) } ,
77104 ] ,
@@ -110,9 +137,19 @@ describe('FileDownloadLinkComponent', () => {
110137 fixture . detectChanges ( ) ;
111138 const link = fixture . debugElement . query ( By . css ( 'a' ) ) ;
112139 expect ( link . injector . get ( RouterLinkDirectiveStub ) . routerLink ) . toContain ( new URLCombiner ( getBitstreamModuleRoute ( ) , bitstream . uuid , 'download' ) . toString ( ) ) ;
140+ expect ( link . nativeElement . getAttribute ( 'target' ) ) . toBe ( '_blank' ) ;
113141 const lock = fixture . debugElement . query ( By . css ( '.fa-lock' ) ) ;
114142 expect ( lock ) . toBeNull ( ) ;
115143 } ) ;
144+
145+ it ( 'should keep an explicit isBlank input over the config default' , ( ) => {
146+ component . isBlank = false ;
147+ component . ngOnInit ( ) ;
148+ scheduler . flush ( ) ;
149+ fixture . detectChanges ( ) ;
150+ const link = fixture . debugElement . query ( By . css ( 'a' ) ) ;
151+ expect ( link . nativeElement . getAttribute ( 'target' ) ) . toBe ( '_self' ) ;
152+ } ) ;
116153 } ) ;
117154 describe ( 'when the user has no download rights but has the right to request a copy' , ( ) => {
118155 beforeEach ( waitForAsync ( ( ) => {
0 commit comments