import { describe, test } from 'node:test';
import assert from 'node:assert/strict';
import { Arbiter } from '../../src/core/Arbiter.js';

describe('Traversal edge cases', () => {
  test('shortestPathLength returns Infinity for missing nodes', () => {
    const arbiter = new Arbiter();
    arbiter.addNode('a', 'node');
    assert.strictEqual(arbiter.traversal.shortestPathLength('a', 'missing'), Infinity);
  });

  test('shortestPathLength finds a two-hop path', () => {
    const arbiter = new Arbiter();
    arbiter.addNode('a', 'node');
    arbiter.addNode('b', 'node');
    arbiter.addNode('c', 'node');
    arbiter.addRelation('a', 'links', 'b');
    arbiter.addRelation('b', 'links', 'c');

    assert.strictEqual(arbiter.traversal.shortestPathLength('a', 'c'), 2);
  });

  test('walk returns empty path for unknown start', () => {
    const arbiter = new Arbiter();
    assert.deepStrictEqual(arbiter.traversal.walk('missing', 3), []);
  });

  test('walk stops when no neighbors are present', () => {
    const arbiter = new Arbiter();
    arbiter.addNode('solo', 'node');
    const path = arbiter.traversal.walk('solo', 5);
    assert.deepStrictEqual(path, ['solo']);
  });
});
