import test from 'node:test';
import assert from 'node:assert/strict';
import { extractMentionNames, mergeMentionMemberIds } from './comment-mentions';

test('extractMentionNames reads @memberName mentions from comment content', () => {
  assert.deepEqual(extractMentionNames('请 @Alice 和 @张三 看一下'), ['Alice', '张三']);
});

test('mergeMentionMemberIds keeps text mention matches before explicit selection and dedupes', () => {
  const ids = mergeMentionMemberIds({
    content: '请 @Alice 看一下',
    explicitMemberIds: ['m-bob', 'm-alice'],
    members: [
      { id: 'm-alice', name: 'Alice' },
      { id: 'm-bob', name: 'Bob' },
    ],
  });

  assert.deepEqual(ids, ['m-alice', 'm-bob']);
});
