📄 src/isni/isni.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 { ISNIAdapter } from './index';
17
18describe('ISNIAdapter.normalize', () => {
19  it('strips spaces', () => {
20    expect(ISNIAdapter.normalize('0000 0001 2103 2683')).toBe('0000000121032683');
21  });
22});
23
24describe('ISNIAdapter.display', () => {
25  it('groups into 4x4', () => {
26    expect(ISNIAdapter.display('0000000121032683')).toBe('0000 0001 2103 2683');
27  });
28});
29
30describe('ISNIAdapter.validate', () => {
31  it('accepts valid ISNI', () => {
32    expect(ISNIAdapter.validate('0000000121032683').valid).toBe(true);
33  });
34  it('rejects wrong check digit', () => {
35    expect(ISNIAdapter.validate('0000000121032680').valid).toBe(false);
36  });
37  it('rejects null', () => {
38    expect(ISNIAdapter.validate(null).valid).toBe(false);
39  });
40});
41
42describe('ISNIAdapter.toLinkedDataUri', () => {
43  it('returns isni.org URI', () => {
44    expect(ISNIAdapter.toLinkedDataUri('0000 0001 2103 2683')).toBe('https://isni.org/isni/0000000121032683');
45  });
46});
47