1- import { HandleService } from './handle.service' ;
1+ import { HandleService , CANONICAL_PREFIX_KEY } from './handle.service' ;
22import { TestBed } from '@angular/core/testing' ;
33import { ConfigurationDataServiceStub } from './testing/configuration-data.service.stub' ;
44import { ConfigurationDataService } from '../core/data/configuration-data.service' ;
5- import { of as observableOf } from 'rxjs' ;
5+ import { createSuccessfulRemoteDataObject$ } from './remote-data.utils' ;
6+ import { ConfigurationProperty } from '../core/shared/configuration-property.model' ;
67
78describe ( 'HandleService' , ( ) => {
89 let service : HandleService ;
@@ -22,7 +23,11 @@ describe('HandleService', () => {
2223
2324 describe ( `normalizeHandle` , ( ) => {
2425 it ( 'should normalize a handle url with custom conical prefix with trailing slash' , ( done : DoneFn ) => {
25- service . canonicalPrefix$ = observableOf ( 'https://hdl.handle.net/' ) ;
26+ spyOn ( configurationService , 'findByPropertyName' ) . and . returnValue ( createSuccessfulRemoteDataObject$ ( {
27+ ... new ConfigurationProperty ( ) ,
28+ name : CANONICAL_PREFIX_KEY ,
29+ values : [ 'https://hdl.handle.net/' ] ,
30+ } ) ) ;
2631
2732 service . normalizeHandle ( 'https://hdl.handle.net/123456789/123456' ) . subscribe ( ( handle : string | null ) => {
2833 expect ( handle ) . toBe ( '123456789/123456' ) ;
@@ -31,7 +36,11 @@ describe('HandleService', () => {
3136 } ) ;
3237
3338 it ( 'should normalize a handle url with custom conical prefix without trailing slash' , ( done : DoneFn ) => {
34- service . canonicalPrefix$ = observableOf ( 'https://hdl.handle.net' ) ;
39+ spyOn ( configurationService , 'findByPropertyName' ) . and . returnValue ( createSuccessfulRemoteDataObject$ ( {
40+ ... new ConfigurationProperty ( ) ,
41+ name : CANONICAL_PREFIX_KEY ,
42+ values : [ 'https://hdl.handle.net/' ] ,
43+ } ) ) ;
3544
3645 service . normalizeHandle ( 'https://hdl.handle.net/123456789/123456' ) . subscribe ( ( handle : string | null ) => {
3746 expect ( handle ) . toBe ( '123456789/123456' ) ;
0 commit comments