@@ -296,30 +296,45 @@ describe('fetch-orcid.js', () => {
296296 '12345' ,
297297 'https://scopus.com/12345'
298298 )
299- expect ( node . textContent ) . toContain ( 'Scopus ID: 12345' )
299+ expect ( node . textContent ) . toBe ( 'Scopus ID: 12345 (https://scopus.com/12345) ' )
300300 const anchor = node . querySelector ( 'a' )
301301 expect ( anchor ) . not . toBeNull ( )
302302 expect ( anchor ! . href ) . toBe ( 'https://scopus.com/12345' )
303303 expect ( anchor ! . textContent ) . toBe ( 'https://scopus.com/12345' )
304304 } )
305305
306- it ( 'renders value as a link and IGNORES url parameter when value IS a URL' , ( ) => {
306+ it ( 'renders value as a link and NO url in brackets when value IS a URL and matches url param ' , ( ) => {
307307 const node = otherIdsTextNode (
308308 'ResearcherID' ,
309309 'https://researcherid.com/rid/H-1234-2012' ,
310- 'https://some-other-url .com'
310+ 'https://researcherid .com/rid/H-1234-2012 '
311311 )
312- // This is the NEW behavior we want.
313- // Currently it would probably render "ResearcherID: https://researcherid.com/rid/H-1234-2012 (https://some-other-url.com)"
312+ expect ( node . textContent ) . toBe ( 'ResearcherID: https://researcherid.com/rid/H-1234-2012' )
314313 const anchor = node . querySelector ( 'a' )
315314 expect ( anchor ) . not . toBeNull ( )
316315 expect ( anchor ! . href ) . toBe ( 'https://researcherid.com/rid/H-1234-2012' )
317- expect ( anchor ! . textContent ) . toBe (
318- 'https://researcherid.com/rid/H-1234-2012'
316+ } )
317+
318+ it ( 'renders value as link and url in brackets when value is a URL but different from url param' , ( ) => {
319+ const node = otherIdsTextNode (
320+ 'ResearcherID' ,
321+ 'https://researcherid.com/rid/H-1234-2012' ,
322+ 'https://some-other-url.com'
319323 )
324+ expect ( node . textContent ) . toContain ( 'ResearcherID: https://researcherid.com/rid/H-1234-2012' )
325+ expect ( node . textContent ) . toContain ( '(https://some-other-url.com' )
326+ const anchors = node . querySelectorAll ( 'a' )
327+ expect ( anchors . length ) . toBe ( 2 )
328+ expect ( anchors [ 0 ] . href ) . toBe ( 'https://researcherid.com/rid/H-1234-2012' )
329+ expect ( anchors [ 1 ] . href ) . toContain ( 'https://some-other-url.com' )
330+ } )
320331
321- // Ensure the other URL is NOT present
322- expect ( node . textContent ) . not . toContain ( 'https://some-other-url.com' )
332+ it ( 'renders only url when value is empty' , ( ) => {
333+ const node = otherIdsTextNode ( 'Label' , '' , 'https://example.com' )
334+ expect ( node . textContent ) . toContain ( 'Label: https://example.com' )
335+ const anchor = node . querySelector ( 'a' )
336+ expect ( anchor ) . not . toBeNull ( )
337+ expect ( anchor ! . href ) . toContain ( 'https://example.com' )
323338 } )
324339 } )
325340
0 commit comments