Files
factory/lib/wiki-graph/tests/parser.test.ts
vitya ca669d96e1 feat(lib): bundle MCP servers from .common/lib into factory/lib/
Copies source (no node_modules, dist, .tasks, .wiki, __pycache__) for:
- projects-meta-mcp v2.25.0 (TypeScript/Node)
- wiki-graph v0.3.1 (TypeScript/Node)
- interns-mcp v0.3.3 (Python/FastMCP)

.gitignore: exclude lib build artefacts (node_modules, dist, .venv, __pycache__, *.pyc)
bootstrap.ps1: add MCP build step — npm install+build for TS servers, venv+pip for Python

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-11 13:17:29 +03:00

35 lines
1.2 KiB
TypeScript

import { describe, test, expect } from 'vitest';
import { extractLinks } from '../src/parser.js';
describe('extractLinks', () => {
test('extracts a simple [[slug]] link', () => {
const links = extractLinks('see [[clock-modulation]] for details');
expect(links).toEqual([{ target: 'clock-modulation', alias: null }]);
});
test('takes left part of [[slug|alias]]', () => {
const links = extractLinks('[[euclidean-rhythms|Euclidean Rhythms]]');
expect(links).toEqual([
{ target: 'euclidean-rhythms', alias: 'Euclidean Rhythms' },
]);
});
test('extracts multiple links across the document', () => {
const links = extractLinks('[[a]] then\nsome text [[b|B]] and [[c]]');
expect(links).toEqual([
{ target: 'a', alias: null },
{ target: 'b', alias: 'B' },
{ target: 'c', alias: null },
]);
});
test('keeps placeholder targets verbatim (resolver decides dangling)', () => {
const links = extractLinks('TODO link [[<module-name>]]');
expect(links).toEqual([{ target: '<module-name>', alias: null }]);
});
test('returns empty for content with no wikilinks', () => {
expect(extractLinks('plain text, a [single] bracket, no links')).toEqual([]);
});
});