📄 src/orcid/orcid.test.ts
D-OPEN SOVEREIGN
1/*
2 * Copyright (c) 2026 DataPond D-Library Pty Ltd. ("The Sanctuary")
3 * Non-Profit Public Library — The World Library
4 * 
5 * D-SAFE Certification issued by POND Enterprise.
6 * Published under the D-Open Code Sovereign Licence v1.0 framework
7 * DataPond D-Library All exclusive Right reserved on modifiying the code - CC Attribution to data pond, Non modifiable, Non Commercial.
8 * https://registry.world.bibliotech.com/licence
9 * Source code donated to DataPond D-Library by it's author: data pond.
10 * 
11 * Technical Guardian ("The Shield"): Pond Enterprise Pty Ltd. (ACN 694 747 987)
12 * All liability claims about D-SAFE certification issues coming from the published D-Safe direction must be addressed with Pond Enterprise Pty Ltd.
13 * Code Modification automatically voids the certified liability protection provided by Pond Enterprise.
14 */
15import { describe, expect, it } from 'vitest';
16import { ORCIDAdapter } from './index';
17
18describe('ORCIDAdapter.normalize', () => {
19  it('inserts hyphens for compact 16-char input', () => {
20    expect(ORCIDAdapter.normalize('0000000218250097')).toBe('0000-0002-1825-0097');
21  });
22  it('passes through already-hyphenated ORCID', () => {
23    expect(ORCIDAdapter.normalize('0000-0002-1825-0097')).toBe('0000-0002-1825-0097');
24  });
25});
26
27describe('ORCIDAdapter.validate', () => {
28  it('accepts valid ORCID', () => {
29    expect(ORCIDAdapter.validate('0000-0002-1825-0097').valid).toBe(true);
30  });
31  it('rejects wrong check digit', () => {
32    expect(ORCIDAdapter.validate('0000-0002-1825-0090').valid).toBe(false);
33  });
34  it('rejects null', () => {
35    expect(ORCIDAdapter.validate(null).valid).toBe(false);
36  });
37});
38
39describe('ORCIDAdapter.toLinkedDataUri', () => {
40  it('returns orcid.org URI', () => {
41    expect(ORCIDAdapter.toLinkedDataUri('0000000218250097')).toBe('https://orcid.org/0000-0002-1825-0097');
42  });
43});
44