import { describe, it, expect } from 'vitest';
import { SessionIndexer, tokenize } from './indexer.js';

describe('session indexer', () => {
  it('tokenizes text with stopword filtering', () => {
    const tokens = tokenize('Deploy the backend service to production and verify logs');
    expect(tokens).toContain('deploy');
    expect(tokens).toContain('backend');
    expect(tokens).toContain('service');
    expect(tokens).not.toContain('the');
  });

  it('extracts top keywords and topics', () => {
    const indexer = new SessionIndexer({ maxKeywords: 5 });
    const metadata = indexer.indexText('deploy deploy backend service backend api release');

    expect(metadata.keywords.length).toBeLessThanOrEqual(5);
    expect(metadata.keywords).toContain('deploy');
    expect(metadata.topics.length).toBeLessThanOrEqual(3);
  });
});
