40 lines
2.1 KiB
JavaScript
40 lines
2.1 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { projects, processes, source, revision } from '../content.js';
|
|
test('Evidence mappings use real process IDs and complete translations', () => {
|
|
assert.equal(processes.length, 8);
|
|
const ids = new Set(processes.map(p => p.code));
|
|
assert.equal(ids.size, 8);
|
|
assert.equal(new Set(projects.map(p => p.id)).size, projects.length);
|
|
for (const p of projects) {
|
|
for (const key of ['kind', 'title', 'name', 'intro', 'context', 'implementation', 'decisions']) {
|
|
assert.equal(p[key].length, 2, `${p.id}.${key}`);
|
|
assert.ok(p[key].every(s => typeof s === 'string' && s.length > 0));
|
|
}
|
|
for (const e of p.evidence) {
|
|
assert.ok(e.codes.every(c => ids.has(c)), e.path);
|
|
assert.ok(e.label.length === 2 && e.label.every(Boolean));
|
|
const url = new URL(source(e.path, e.directory, p));
|
|
const pin = p.repository?.revision || revision;
|
|
assert.equal(url.hostname, p.repository ? new URL(p.repository.url).hostname : 'github.com');
|
|
assert.ok(url.pathname.includes(pin));
|
|
assert.equal(decodeURIComponent(url.pathname.split(`${pin}/`)[1]), e.path);
|
|
}
|
|
}
|
|
});
|
|
test('Collaboration gaps remain explicit rather than claiming unsupported evidence', () => {
|
|
for (const code of ['B1-K2-W1', 'B1-K2-W2', 'B1-K2-W3']) {
|
|
assert.ok(!projects.some(p => p.evidence.some(e => e.codes.includes(code))));
|
|
}
|
|
});
|
|
|
|
test('Repository links distinguish GitHub and Gitea and encode paths', () => {
|
|
const revision = 'a'.repeat(40);
|
|
const github = { repository: { url: 'https://github.com/example/repo', revision, forge: 'github' } };
|
|
const gitea = { repository: { url: 'https://codealvin.xyz/example/repo', revision, forge: 'gitea' } };
|
|
assert.equal(source('a b/test.md', false, github), github.repository.url + '/blob/' + revision + '/a%20b/test.md');
|
|
assert.equal(source('', true, github), github.repository.url + '/tree/' + revision);
|
|
assert.equal(source('src', true, gitea), gitea.repository.url + '/src/commit/' + revision + '/src');
|
|
assert.equal(source('a b.md', false, gitea), gitea.repository.url + '/src/commit/' + revision + '/a%20b.md');
|
|
});
|