import { describe, it, expect } from 'vitest';
import { extractWikiLinks, splitWikiLinks } from './wikilinks';

describe('extractWikiLinks', () => {
  it('pulls distinct titles from [[links]]', () => {
    expect(extractWikiLinks('See [[Strahd]] and [[Barovia]] and [[Strahd]] again')).toEqual(['Strahd', 'Barovia']);
  });
  it('trims whitespace and ignores empties', () => {
    expect(extractWikiLinks('a [[  Ravenloft  ]] b [[]] c')).toEqual(['Ravenloft']);
  });
});

describe('splitWikiLinks', () => {
  it('splits text into plain and link segments', () => {
    const parts = splitWikiLinks('go to [[Town]] now');
    expect(parts).toEqual([
      { text: 'go to ' },
      { text: 'Town', link: 'Town' },
      { text: ' now' },
    ]);
  });
});
