import test from 'node:test';
import assert from 'node:assert/strict';
import { parseSuggestionsFromLlm } from './replySuggestionParse.js';

test('parseSuggestionsFromLlm parses JSON object with suggestions key', () => {
  const raw = '{"suggestions":["Hi there","Thanks for waiting","We can help with that"]}';
  assert.deepEqual(parseSuggestionsFromLlm(raw), [
    'Hi there',
    'Thanks for waiting',
    'We can help with that',
  ]);
});

test('parseSuggestionsFromLlm parses plain JSON array', () => {
  assert.deepEqual(parseSuggestionsFromLlm('["One","Two","Three"]'), ['One', 'Two', 'Three']);
});

test('parseSuggestionsFromLlm falls back to plain text reply', () => {
  assert.deepEqual(parseSuggestionsFromLlm("You're welcome — glad we could help!"), [
    "You're welcome — glad we could help!",
  ]);
});

test('parseSuggestionsFromLlm parses numbered list', () => {
  const raw = `1. First option
2. Second option
3. Third option`;
  assert.deepEqual(parseSuggestionsFromLlm(raw), ['First option', 'Second option', 'Third option']);
});
