@@ -19,7 +19,7 @@ import { PaginatedList } from '../data/paginated-list.model';
1919import { Bitstream } from '../shared/bitstream.model' ;
2020import { MetadataValue } from '../shared/metadata.models' ;
2121
22- import { MetadataService } from './metadata .service' ;
22+ import { HeadTagService } from './head-tag .service' ;
2323import { RootDataService } from '../data/root-data.service' ;
2424import { Bundle } from '../shared/bundle.model' ;
2525import { createPaginatedList } from '../../shared/testing/utils.test' ;
@@ -31,8 +31,8 @@ import { AddMetaTagAction, ClearMetaTagAction } from './meta-tag.actions';
3131import { AuthorizationDataService } from '../data/feature-authorization/authorization-data.service' ;
3232import { AppConfig } from '../../../config/app-config.interface' ;
3333
34- describe ( 'MetadataService ' , ( ) => {
35- let metadataService : MetadataService ;
34+ describe ( 'HeadTagService ' , ( ) => {
35+ let headTagService : HeadTagService ;
3636
3737 let meta : Meta ;
3838
@@ -41,7 +41,6 @@ describe('MetadataService', () => {
4141 let dsoNameService : DSONameService ;
4242
4343 let bundleDataService ;
44- let bitstreamDataService ;
4544 let rootService : RootDataService ;
4645 let translateService : TranslateService ;
4746 let hardRedirectService : HardRedirectService ;
@@ -59,9 +58,6 @@ describe('MetadataService', () => {
5958 rootService = jasmine . createSpyObj ( {
6059 findRoot : createSuccessfulRemoteDataObject$ ( { dspaceVersion : 'mock-dspace-version' } )
6160 } ) ;
62- bitstreamDataService = jasmine . createSpyObj ( {
63- findListByHref : createSuccessfulRemoteDataObject$ ( createPaginatedList ( [ MockBitstream3 ] ) ) ,
64- } ) ;
6561 bundleDataService = jasmine . createSpyObj ( {
6662 findByItemAndName : mockBundleRD$ ( [ MockBitstream3 ] )
6763 } ) ;
@@ -102,15 +98,13 @@ describe('MetadataService', () => {
10298 }
10399 } as any ;
104100
105- metadataService = new MetadataService (
101+ headTagService = new HeadTagService (
106102 router ,
107103 translateService ,
108104 meta ,
109105 title ,
110106 dsoNameService ,
111107 bundleDataService ,
112- bitstreamDataService ,
113- undefined ,
114108 rootService ,
115109 store ,
116110 hardRedirectService ,
@@ -120,7 +114,7 @@ describe('MetadataService', () => {
120114 } ) ;
121115
122116 it ( 'items page should set meta tags' , fakeAsync ( ( ) => {
123- ( metadataService as any ) . processRouteChange ( {
117+ ( headTagService as any ) . processRouteChange ( {
124118 data : {
125119 value : {
126120 dso : createSuccessfulRemoteDataObject ( ItemMock ) ,
@@ -147,7 +141,7 @@ describe('MetadataService', () => {
147141 } ) ) ;
148142
149143 it ( 'items page should set meta tags as published Thesis' , fakeAsync ( ( ) => {
150- ( metadataService as any ) . processRouteChange ( {
144+ ( headTagService as any ) . processRouteChange ( {
151145 data : {
152146 value : {
153147 dso : createSuccessfulRemoteDataObject ( mockPublisher ( mockType ( ItemMock , 'Thesis' ) ) ) ,
@@ -166,7 +160,7 @@ describe('MetadataService', () => {
166160 } ) ) ;
167161
168162 it ( 'items page should set meta tags as published Technical Report' , fakeAsync ( ( ) => {
169- ( metadataService as any ) . processRouteChange ( {
163+ ( headTagService as any ) . processRouteChange ( {
170164 data : {
171165 value : {
172166 dso : createSuccessfulRemoteDataObject ( mockPublisher ( mockType ( ItemMock , 'Technical Report' ) ) ) ,
@@ -182,7 +176,7 @@ describe('MetadataService', () => {
182176
183177 it ( 'route titles should overwrite dso titles' , fakeAsync ( ( ) => {
184178 ( translateService . get as jasmine . Spy ) . and . returnValues ( of ( 'DSpace :: ' ) , of ( 'Translated Route Title' ) ) ;
185- ( metadataService as any ) . processRouteChange ( {
179+ ( headTagService as any ) . processRouteChange ( {
186180 data : {
187181 value : {
188182 dso : createSuccessfulRemoteDataObject ( ItemMock ) ,
@@ -198,7 +192,7 @@ describe('MetadataService', () => {
198192
199193 it ( 'other navigation should add title and description' , fakeAsync ( ( ) => {
200194 ( translateService . get as jasmine . Spy ) . and . returnValues ( of ( 'DSpace :: ' ) , of ( 'Dummy Title' ) , of ( 'This is a dummy item component for testing!' ) ) ;
201- ( metadataService as any ) . processRouteChange ( {
195+ ( headTagService as any ) . processRouteChange ( {
202196 data : {
203197 value : {
204198 title : 'Dummy Title' ,
@@ -220,14 +214,14 @@ describe('MetadataService', () => {
220214
221215 describe ( `listenForRouteChange` , ( ) => {
222216 it ( `should call processRouteChange` , fakeAsync ( ( ) => {
223- spyOn ( metadataService as any , 'processRouteChange' ) . and . callFake ( ( ) => undefined ) ;
224- metadataService . listenForRouteChange ( ) ;
217+ spyOn ( headTagService as any , 'processRouteChange' ) . and . callFake ( ( ) => undefined ) ;
218+ headTagService . listenForRouteChange ( ) ;
225219 tick ( ) ;
226- expect ( ( metadataService as any ) . processRouteChange ) . toHaveBeenCalled ( ) ;
220+ expect ( ( headTagService as any ) . processRouteChange ) . toHaveBeenCalled ( ) ;
227221 } ) ) ;
228222 it ( `should add Generator` , fakeAsync ( ( ) => {
229- spyOn ( metadataService as any , 'processRouteChange' ) . and . callFake ( ( ) => undefined ) ;
230- metadataService . listenForRouteChange ( ) ;
223+ spyOn ( headTagService as any , 'processRouteChange' ) . and . callFake ( ( ) => undefined ) ;
224+ headTagService . listenForRouteChange ( ) ;
231225 tick ( ) ;
232226 expect ( meta . addTag ) . toHaveBeenCalledWith ( {
233227 name : 'Generator' ,
@@ -238,7 +232,7 @@ describe('MetadataService', () => {
238232
239233 describe ( 'citation_abstract_html_url' , ( ) => {
240234 it ( 'should use dc.identifier.uri if available' , fakeAsync ( ( ) => {
241- ( metadataService as any ) . processRouteChange ( {
235+ ( headTagService as any ) . processRouteChange ( {
242236 data : {
243237 value : {
244238 dso : createSuccessfulRemoteDataObject ( mockUri ( ItemMock , 'https://ddg.gg' ) ) ,
@@ -253,7 +247,7 @@ describe('MetadataService', () => {
253247 } ) ) ;
254248
255249 it ( 'should use current route as fallback' , fakeAsync ( ( ) => {
256- ( metadataService as any ) . processRouteChange ( {
250+ ( headTagService as any ) . processRouteChange ( {
257251 data : {
258252 value : {
259253 dso : createSuccessfulRemoteDataObject ( mockUri ( ItemMock ) ) ,
@@ -270,7 +264,7 @@ describe('MetadataService', () => {
270264
271265 describe ( 'citation_*_institution / citation_publisher' , ( ) => {
272266 it ( 'should use citation_dissertation_institution tag for dissertations' , fakeAsync ( ( ) => {
273- ( metadataService as any ) . processRouteChange ( {
267+ ( headTagService as any ) . processRouteChange ( {
274268 data : {
275269 value : {
276270 dso : createSuccessfulRemoteDataObject ( mockPublisher ( mockType ( ItemMock , 'Thesis' ) ) ) ,
@@ -287,7 +281,7 @@ describe('MetadataService', () => {
287281 } ) ) ;
288282
289283 it ( 'should use citation_tech_report_institution tag for tech reports' , fakeAsync ( ( ) => {
290- ( metadataService as any ) . processRouteChange ( {
284+ ( headTagService as any ) . processRouteChange ( {
291285 data : {
292286 value : {
293287 dso : createSuccessfulRemoteDataObject ( mockPublisher ( mockType ( ItemMock , 'Technical Report' ) ) ) ,
@@ -304,7 +298,7 @@ describe('MetadataService', () => {
304298 } ) ) ;
305299
306300 it ( 'should use citation_publisher for other item types' , fakeAsync ( ( ) => {
307- ( metadataService as any ) . processRouteChange ( {
301+ ( headTagService as any ) . processRouteChange ( {
308302 data : {
309303 value : {
310304 dso : createSuccessfulRemoteDataObject ( mockPublisher ( mockType ( ItemMock , 'Some Other Type' ) ) ) ,
@@ -325,7 +319,7 @@ describe('MetadataService', () => {
325319 it ( 'should link to primary Bitstream URL regardless of format' , fakeAsync ( ( ) => {
326320 ( bundleDataService . findByItemAndName as jasmine . Spy ) . and . returnValue ( mockBundleRD$ ( [ ] , MockBitstream3 ) ) ;
327321
328- ( metadataService as any ) . processRouteChange ( {
322+ ( headTagService as any ) . processRouteChange ( {
329323 data : {
330324 value : {
331325 dso : createSuccessfulRemoteDataObject ( ItemMock ) ,
@@ -344,7 +338,7 @@ describe('MetadataService', () => {
344338 ( bundleDataService . findByItemAndName as jasmine . Spy ) . and . returnValue ( mockBundleRD$ ( [ MockBitstream3 ] ) ) ;
345339 ( authorizationService . isAuthorized as jasmine . Spy ) . and . returnValue ( observableOf ( false ) ) ;
346340
347- ( metadataService as any ) . processRouteChange ( {
341+ ( headTagService as any ) . processRouteChange ( {
348342 data : {
349343 value : {
350344 dso : createSuccessfulRemoteDataObject ( ItemMock ) ,
@@ -361,7 +355,7 @@ describe('MetadataService', () => {
361355 it ( 'should link to first and only Bitstream regardless of format' , fakeAsync ( ( ) => {
362356 ( bundleDataService . findByItemAndName as jasmine . Spy ) . and . returnValue ( mockBundleRD$ ( [ MockBitstream3 ] ) ) ;
363357
364- ( metadataService as any ) . processRouteChange ( {
358+ ( headTagService as any ) . processRouteChange ( {
365359 data : {
366360 value : {
367361 dso : createSuccessfulRemoteDataObject ( ItemMock ) ,
@@ -381,13 +375,10 @@ describe('MetadataService', () => {
381375 beforeEach ( ( ) => {
382376 bitstreams = [ MockBitstream2 , MockBitstream3 , MockBitstream1 ] ;
383377 ( bundleDataService . findByItemAndName as jasmine . Spy ) . and . returnValue ( mockBundleRD$ ( bitstreams ) ) ;
384- ( bitstreamDataService . findListByHref as jasmine . Spy ) . and . returnValues (
385- ...mockBitstreamPages$ ( bitstreams ) . map ( bp => createSuccessfulRemoteDataObject$ ( bp ) ) ,
386- ) ;
387378 } ) ;
388379
389380 it ( 'should link to first Bitstream with allowed format' , fakeAsync ( ( ) => {
390- ( metadataService as any ) . processRouteChange ( {
381+ ( headTagService as any ) . processRouteChange ( {
391382 data : {
392383 value : {
393384 dso : createSuccessfulRemoteDataObject ( ItemMock ) ,
@@ -412,13 +403,10 @@ describe('MetadataService', () => {
412403 beforeEach ( ( ) => {
413404 bitstreams = [ MockBitstream1 , MockBitstream3 , MockBitstream2 ] ;
414405 ( bundleDataService . findByItemAndName as jasmine . Spy ) . and . returnValue ( mockBundleRD$ ( bitstreams ) ) ;
415- ( bitstreamDataService . findListByHref as jasmine . Spy ) . and . returnValues (
416- ...mockBitstreamPages$ ( bitstreams ) . map ( bp => createSuccessfulRemoteDataObject$ ( bp ) ) ,
417- ) ;
418406 } ) ;
419407
420408 it ( `shouldn't add a citation_pdf_url meta tag` , fakeAsync ( ( ) => {
421- ( metadataService as any ) . processRouteChange ( {
409+ ( headTagService as any ) . processRouteChange ( {
422410 data : {
423411 value : {
424412 dso : createSuccessfulRemoteDataObject ( ItemMock ) ,
@@ -437,7 +425,7 @@ describe('MetadataService', () => {
437425
438426 describe ( 'tagstore' , ( ) => {
439427 beforeEach ( fakeAsync ( ( ) => {
440- ( metadataService as any ) . processRouteChange ( {
428+ ( headTagService as any ) . processRouteChange ( {
441429 data : {
442430 value : {
443431 dso : createSuccessfulRemoteDataObject ( ItemMock ) ,
0 commit comments