397777089e
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
45 lines
1.6 KiB
JavaScript
45 lines
1.6 KiB
JavaScript
import { describe, it, expect } from 'vitest';
|
|
import { recommendNode } from './observer-recommended-node.mjs';
|
|
|
|
const MAP = {
|
|
feature: ['#19'],
|
|
refactor: ['#11', '#12', '#43'],
|
|
question: [],
|
|
other: [],
|
|
};
|
|
|
|
describe('recommendNode', () => {
|
|
it('returns first live node ID for a known classification', () => {
|
|
expect(recommendNode('feature', MAP, { '#19': false })).toBe('#19');
|
|
});
|
|
|
|
it('skips dormant first node, returns next live', () => {
|
|
expect(recommendNode('refactor', MAP, { '#11': true, '#12': false, '#43': false })).toBe('#12');
|
|
});
|
|
|
|
it('returns null when all recommended nodes are dormant', () => {
|
|
expect(recommendNode('refactor', MAP, { '#11': true, '#12': true, '#43': true })).toBeNull();
|
|
});
|
|
|
|
it('returns null for classification absent from map', () => {
|
|
expect(recommendNode('nonexistent', MAP, {})).toBeNull();
|
|
});
|
|
|
|
it('returns null for empty-array classification (question/memory-sync)', () => {
|
|
expect(recommendNode('question', MAP, {})).toBeNull();
|
|
expect(recommendNode('other', MAP, {})).toBeNull();
|
|
});
|
|
|
|
it('treats missing dormancy entry as live (defensive, parity with missed-activations)', () => {
|
|
// missed-activations uses dormancy[id] === false; recommendNode mirrors:
|
|
// unknown/missing → not live (paranoid — only positive false counts as live).
|
|
expect(recommendNode('feature', MAP, {})).toBeNull();
|
|
});
|
|
|
|
it('handles null/undefined inputs without throwing', () => {
|
|
expect(recommendNode(null, MAP, {})).toBeNull();
|
|
expect(recommendNode('feature', null, {})).toBeNull();
|
|
expect(recommendNode('feature', MAP, null)).toBeNull();
|
|
});
|
|
});
|