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 [[]]'); expect(links).toEqual([{ target: '', alias: null }]); }); test('returns empty for content with no wikilinks', () => { expect(extractLinks('plain text, a [single] bracket, no links')).toEqual([]); }); });