@@ -15,7 +15,10 @@ import {
1515 getTestScheduler ,
1616} from 'jasmine-marbles' ;
1717import { of } from 'rxjs' ;
18- import { APP_DATA_SERVICES_MAP } from 'src/config/app-config.interface' ;
18+ import {
19+ APP_CONFIG ,
20+ APP_DATA_SERVICES_MAP ,
21+ } from 'src/config/app-config.interface' ;
1922
2023import { getBitstreamModuleRoute } from '../../app-routing-paths' ;
2124import { ConfigurationDataService } from '../../core/data/configuration-data.service' ;
@@ -44,6 +47,14 @@ describe('FileDownloadLinkComponent', () => {
4447 let configurationDataService : ConfigurationDataService ;
4548 let storeMock : any ;
4649
50+ const mockAppConfig = {
51+ item : {
52+ bitstream : {
53+ openDownloadLinksInNewTab : true ,
54+ } ,
55+ } ,
56+ } ;
57+
4758 const itemRequestStub = Object . assign ( new ItemRequest ( ) , {
4859 token : 'item-request-token' ,
4960 requestName : 'requester name' ,
@@ -95,6 +106,7 @@ describe('FileDownloadLinkComponent', () => {
95106 { provide : ActivatedRoute , useValue : activatedRoute } ,
96107 { provide : Store , useValue : storeMock } ,
97108 { provide : APP_DATA_SERVICES_MAP , useValue : { } } ,
109+ { provide : APP_CONFIG , useValue : mockAppConfig } ,
98110 { provide : ConfigurationDataService , useValue : configurationDataService } ,
99111 ] ,
100112 } )
@@ -135,9 +147,19 @@ describe('FileDownloadLinkComponent', () => {
135147 fixture . detectChanges ( ) ;
136148 const link = fixture . debugElement . query ( By . css ( 'a' ) ) ;
137149 expect ( link . injector . get ( RouterLinkDirectiveStub ) . routerLink ) . toContain ( new URLCombiner ( getBitstreamModuleRoute ( ) , bitstream . uuid , 'download' ) . toString ( ) ) ;
150+ expect ( link . nativeElement . getAttribute ( 'target' ) ) . toBe ( '_blank' ) ;
138151 const lock = fixture . debugElement . query ( By . css ( '.fa-lock' ) ) ;
139152 expect ( lock ) . toBeNull ( ) ;
140153 } ) ;
154+
155+ it ( 'should keep an explicit isBlank input over the config default' , ( ) => {
156+ component . isBlank = false ;
157+ component . ngOnInit ( ) ;
158+ scheduler . flush ( ) ;
159+ fixture . detectChanges ( ) ;
160+ const link = fixture . debugElement . query ( By . css ( 'a' ) ) ;
161+ expect ( link . nativeElement . getAttribute ( 'target' ) ) . toBe ( '_self' ) ;
162+ } ) ;
141163 } ) ;
142164
143165 describe ( 'when the user has no download rights but has the right to request a copy' , ( ) => {
0 commit comments