397777089e
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
80 lines
2.4 KiB
JavaScript
80 lines
2.4 KiB
JavaScript
import { describe, it, expect } from 'vitest';
|
|
import { buildClassificationMap, buildDormancyMap } from './registry-to-classification-map.mjs';
|
|
|
|
function node(id, status, classificationTriggers) {
|
|
return {
|
|
id,
|
|
status,
|
|
triggers: classificationTriggers.map(c => ({ classification: c, weight: 1.0 })),
|
|
};
|
|
}
|
|
|
|
const registry = {
|
|
nodes: [
|
|
node('#11', 'active', ['refactor', 'cleanup']),
|
|
node('#12', 'active', ['refactor', 'cleanup']),
|
|
node('#17', 'dormant', ['refactor']),
|
|
node('#44', 'deferred', ['feature']),
|
|
node('#1', 'historic', ['analysis']),
|
|
node('#19', 'active', ['feature', 'planning']),
|
|
node('#99', 'active', []), // no classification triggers — ignored
|
|
],
|
|
};
|
|
|
|
describe('buildClassificationMap', () => {
|
|
it('groups active nodes by classification', () => {
|
|
const map = buildClassificationMap(registry);
|
|
expect(map.refactor.sort()).toEqual(['#11', '#12']);
|
|
expect(map.feature).toEqual(['#19']);
|
|
expect(map.planning).toEqual(['#19']);
|
|
expect(map.cleanup.sort()).toEqual(['#11', '#12']);
|
|
});
|
|
|
|
it('excludes dormant nodes', () => {
|
|
const map = buildClassificationMap(registry);
|
|
expect(map.refactor).not.toContain('#17');
|
|
});
|
|
|
|
it('excludes deferred nodes', () => {
|
|
const map = buildClassificationMap(registry);
|
|
expect(map.feature || []).not.toContain('#44');
|
|
});
|
|
|
|
it('excludes historic nodes', () => {
|
|
const map = buildClassificationMap(registry);
|
|
expect(map.analysis).toBeUndefined();
|
|
});
|
|
|
|
it('ignores nodes with no classification triggers', () => {
|
|
const map = buildClassificationMap(registry);
|
|
expect(Object.values(map).flat()).not.toContain('#99');
|
|
});
|
|
|
|
it('returns an empty object on an empty registry', () => {
|
|
expect(buildClassificationMap({ nodes: [] })).toEqual({});
|
|
});
|
|
});
|
|
|
|
describe('buildDormancyMap', () => {
|
|
it('marks dormant nodes true', () => {
|
|
const dorm = buildDormancyMap(registry);
|
|
expect(dorm['#17']).toBe(true);
|
|
});
|
|
|
|
it('marks deferred nodes true', () => {
|
|
const dorm = buildDormancyMap(registry);
|
|
expect(dorm['#44']).toBe(true);
|
|
});
|
|
|
|
it('marks historic nodes true', () => {
|
|
const dorm = buildDormancyMap(registry);
|
|
expect(dorm['#1']).toBe(true);
|
|
});
|
|
|
|
it('marks active nodes false', () => {
|
|
const dorm = buildDormancyMap(registry);
|
|
expect(dorm['#11']).toBe(false);
|
|
expect(dorm['#19']).toBe(false);
|
|
});
|
|
});
|