@@ -5,14 +5,14 @@ import {
55} from '@angular/core/testing' ;
66import { TranslateModule } from '@ngx-translate/core' ;
77import { of } from 'rxjs' ;
8+ import { APP_CONFIG } from 'src/config/app-config.interface' ;
89
910import { BrowseService } from '../../../../../core/browse/browse.service' ;
1011import { BrowseDefinitionDataService } from '../../../../../core/browse/browse-definition-data.service' ;
1112import { ConfigurationDataService } from '../../../../../core/data/configuration-data.service' ;
1213import { ConfigurationProperty } from '../../../../../core/shared/configuration-property.model' ;
1314import { Item } from '../../../../../core/shared/item.model' ;
1415import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/remote-data.utils' ;
15- import { APP_CONFIG } from 'src/config/app-config.interface' ;
1616import { ItemPageOrcidFieldComponent } from './item-page-orcid-field.component' ;
1717
1818describe ( 'ItemPageOrcidFieldComponent' , ( ) => {
@@ -102,6 +102,17 @@ describe('ItemPageOrcidFieldComponent', () => {
102102 expect ( component . hasOrcid ( ) ) . toBe ( false ) ;
103103 } ) ;
104104
105+ it ( 'should set hasOrcidMetadata property on init' , ( ) => {
106+ fixture . detectChanges ( ) ;
107+ expect ( component . hasOrcidMetadata ) . toBe ( true ) ;
108+ } ) ;
109+
110+ it ( 'should set hasOrcidMetadata to false when item has no ORCID' , ( ) => {
111+ component . item = Object . assign ( new Item ( ) , { metadata : { } } ) ;
112+ component . ngOnInit ( ) ;
113+ expect ( component . hasOrcidMetadata ) . toBe ( false ) ;
114+ } ) ;
115+
105116 it ( 'should construct ORCID URL on init' , ( done ) => {
106117 fixture . detectChanges ( ) ;
107118
@@ -111,13 +122,9 @@ describe('ItemPageOrcidFieldComponent', () => {
111122 } ) ;
112123 } ) ;
113124
114- it ( 'should extract ORCID ID on init' , ( done ) => {
125+ it ( 'should extract ORCID ID on init' , ( ) => {
115126 fixture . detectChanges ( ) ;
116-
117- component . orcidId$ . subscribe ( id => {
118- expect ( id ) . toBe ( '0000-0002-1825-0097' ) ;
119- done ( ) ;
120- } ) ;
127+ expect ( component . orcidId ) . toBe ( '0000-0002-1825-0097' ) ;
121128 } ) ;
122129
123130 it ( 'should handle ORCID with leading slash' , ( done ) => {
@@ -138,6 +145,8 @@ describe('ItemPageOrcidFieldComponent', () => {
138145 component . ngOnInit ( ) ;
139146 fixture . detectChanges ( ) ;
140147
148+ expect ( component . orcidId ) . toBe ( '0000-0002-1825-0097' ) ;
149+
141150 component . orcidUrl$ . subscribe ( url => {
142151 expect ( url ) . toBe ( 'https://sandbox.orcid.org/0000-0002-1825-0097' ) ;
143152 done ( ) ;
@@ -149,6 +158,8 @@ describe('ItemPageOrcidFieldComponent', () => {
149158 component . ngOnInit ( ) ;
150159 fixture . detectChanges ( ) ;
151160
161+ expect ( component . orcidId ) . toBeNull ( ) ;
162+
152163 component . orcidUrl$ . subscribe ( url => {
153164 expect ( url ) . toBeNull ( ) ;
154165 done ( ) ;
0 commit comments