11import { describe , test , expect } from 'vitest' ;
22import {
33 isOrcidId ,
4+ unprefixOrcidId ,
5+ ORCID_SANDBOX_PREFIX ,
46 isLinkedIdentityId ,
57 assertIsLinkedIdentityId ,
68} from '../../src/utils/assert' ;
79
10+ describe ( 'unprefixOrcidId' , ( ) => {
11+ test ( 'should remove sandbox prefix from ORCID ID' , ( ) => {
12+ expect ( unprefixOrcidId ( `${ ORCID_SANDBOX_PREFIX } 0009-0007-1106-8413` ) ) . toBe (
13+ '0009-0007-1106-8413' ,
14+ ) ;
15+ } ) ;
16+
17+ test ( 'should return ORCID ID unchanged if no sandbox prefix' , ( ) => {
18+ expect ( unprefixOrcidId ( '0009-0007-1106-8413' ) ) . toBe ( '0009-0007-1106-8413' ) ;
19+ } ) ;
20+ } ) ;
21+
822describe ( 'isOrcidId' , ( ) => {
923 test ( 'should return true for valid ORCID IDs' , ( ) => {
1024 // Valid ORCID ID patterns with correct checksums
1125 expect ( isOrcidId ( '0000-0003-1527-0030' ) ) . toBe ( true ) ;
1226 } ) ;
1327
28+ test ( 'should return true for valid sandbox-prefixed ORCID IDs' , ( ) => {
29+ // Valid sandbox ORCID ID with correct checksum after removing prefix
30+ expect ( isOrcidId ( `${ ORCID_SANDBOX_PREFIX } 0009-0007-1106-8413` ) ) . toBe ( true ) ;
31+ } ) ;
32+
1433 test ( 'should return false for invalid ORCID IDs' , ( ) => {
1534 // Invalid patterns
1635 expect ( isOrcidId ( '0000-0002-1825-009X' ) ) . toBe ( false ) ; // Invalid checksum
@@ -33,6 +52,11 @@ describe('isOrcidId', () => {
3352 expect ( isOrcidId ( 'abc-def-ghi-jkl' ) ) . toBe ( false ) ; // Letters instead of digits
3453 expect ( isOrcidId ( '0000-0000-0000-000@' ) ) . toBe ( false ) ; // Invalid special character
3554 } ) ;
55+
56+ test ( 'should return false for sandbox-prefixed invalid ORCID IDs' , ( ) => {
57+ // Invalid checksum even with sandbox prefix
58+ expect ( isOrcidId ( 'sandbox-0000-0002-1825-009X' ) ) . toBe ( false ) ;
59+ } ) ;
3660} ) ;
3761
3862describe ( 'isLinkedIdentityId' , ( ) => {
0 commit comments