-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuildRuleHelpUrl.test.ts
More file actions
47 lines (34 loc) · 1.29 KB
/
buildRuleHelpUrl.test.ts
File metadata and controls
47 lines (34 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// SPDX-FileCopyrightText: 2025 Digg - Agency for Digital Government
//
// SPDX-License-Identifier: EUPL-1.2
import { buildRuleHelpUrl } from '../../src/rulesets/util/rules-doc.config.js';
describe('buildRuleHelpUrl', () => {
const ORIGINAL_ENV = process.env;
beforeEach(() => {
process.env = { ...ORIGINAL_ENV };
});
afterAll(() => {
process.env = ORIGINAL_ENV;
});
it('bygger korrekt GitHub-länk för regel-ID med punkt (SAK.16)', () => {
process.env.RULES_DOC_REF = 'main';
const url = buildRuleHelpUrl('SAK.16');
expect(url).toBe(
'https://github.com/diggsweden/rest-api-profil-lint-processor/blob/main/GUIDELINES.md#id-sak16'
);
});
it('faller tillbaka till main om RULES_DOC_REF saknas', () => {
delete process.env.RULES_DOC_REF;
const url = buildRuleHelpUrl('FOR.02');
expect(url).toBe(
'https://github.com/diggsweden/rest-api-profil-lint-processor/blob/main/GUIDELINES.md#id-for02'
);
});
it('hanterar redan normaliserade ID:n korrekt', () => {
process.env.RULES_DOC_REF = 'feature/test';
const url = buildRuleHelpUrl('sak16');
expect(url).toBe(
'https://github.com/diggsweden/rest-api-profil-lint-processor/blob/feature/test/GUIDELINES.md#id-sak16'
);
});
});