import { describe, it, expect } from 'vitest';
import { parseMemoryEntries } from '../entries.js';

describe('parseMemoryEntries', () => {
  it('parses a single entry with tags', () => {
    const md = '## project: Indentation\n> tags: style\n\nUse two-space indentation\n';
    const entries = parseMemoryEntries('style.md', md);
    expect(entries).toHaveLength(1);
    expect(entries[0].title).toBe('Indentation');
    expect(entries[0].topic).toBe('project');
    expect(entries[0].tags).toEqual(['style']);
    expect(entries[0].content).toContain('two-space');
  });

  it('parses multiple entries', () => {
    const md = [
      '## project: Style',
      '',
      'Use tab indentation',
      '',
      '## user: Preference',
      '',
      'Prefer pnpm',
      '',
    ].join('\n');
    const entries = parseMemoryEntries('mem.md', md);
    expect(entries).toHaveLength(2);
    expect(entries[0].topic).toBe('project');
    expect(entries[1].topic).toBe('user');
  });
});
