feat: 'did you mean' boot hint, flow compile-time type-test, and demos

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-06-28 02:36:37 -05:00
1 parent cc0044ba6a
commit 9d8088d0a9
7 files changed
+88 -3

No files matched your search

+11 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it, test } from 'vitest';
import { topoSort, GraphNode, subgraphFor } from '../src/graph';
import { topoSort, GraphNode, subgraphFor, nearest } from '../src/graph';
const node = (name: string, needs: string[], provides: string[]): GraphNode =>
({ name, needs, provides, origin: 'test' });
@@ -41,3 +41,13 @@ describe('subgraphFor', () => {
expect(subgraphFor(['user'], ordered).map((n) => n.name)).not.toContain('audit');
});
});
describe('nearest', () => {
it('suggests a close candidate (edit distance <= 2)', () => {
expect(nearest('usr', ['user', 'config', 'db'])).toBe('user');
expect(nearest('confgi', ['user', 'config'])).toBe('config');
});
it('returns undefined when nothing is close', () => {
expect(nearest('zzzzzz', ['user', 'db'])).toBeUndefined();
});
});