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:
7 files changed
+88
-3
No files matched your search
+11
-1
@@ -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();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user