📄 src/issn/issn.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 { ISSNAdapter } from './index';
17
18describe('ISSNAdapter.normalize', () => {
19  it('inserts hyphen for 8-digit input', () => {
20    expect(ISSNAdapter.normalize('00280836')).toBe('0028-0836');
21  });
22  it('passes through already-hyphenated ISSN', () => {
23    expect(ISSNAdapter.normalize('0028-0836')).toBe('0028-0836');
24  });
25});
26
27describe('ISSNAdapter.validate', () => {
28  it.each(['0028-0836', '1476-4687', '0002-9327', '0022-2429'])(
29    'accepts valid ISSN: %s', (input) => {
30      expect(ISSNAdapter.validate(input).valid).toBe(true);
31    }
32  );
33  it.each([
34    ['0028-0835', 'wrong check digit'],
35    ['1476-4680', 'wrong check digit'],
36    [null,        'null'],
37    ['',          'empty'],
38  ])('rejects invalid: %s (%s)', (input) => {
39    expect(ISSNAdapter.validate(input as string).valid).toBe(false);
40  });
41});
42
43describe('ISSNAdapter.toLinkedDataUri', () => {
44  it('returns ISSN Portal URI', () => {
45    expect(ISSNAdapter.toLinkedDataUri('00280836')).toBe('https://portal.issn.org/resource/ISSN/0028-0836');
46  });
47});
48