import assert from 'node:assert/strict';
import test from 'node:test';
import { resolveStaticContentType, shouldAutoCompleteShareReplyParentVerification } from './chat.js';

test('resolveStaticContentType returns html content type for chat resource html files', () => {
  assert.equal(resolveStaticContentType('/tmp/sample.html'), 'text/html; charset=utf-8');
  assert.equal(resolveStaticContentType('/tmp/sample.htm'), 'text/html; charset=utf-8');
});

test('resolveStaticContentType keeps plain text content type for code resources', () => {
  assert.equal(resolveStaticContentType('/tmp/sample.ts'), 'text/plain; charset=utf-8');
  assert.equal(resolveStaticContentType('/tmp/sample.diff'), 'text/plain; charset=utf-8');
});

test('shouldAutoCompleteShareReplyParentVerification only completes answered requests that are not already verified', () => {
  assert.equal(
    shouldAutoCompleteShareReplyParentVerification({
      responseMessageId: 101,
      responseText: '',
      manualVerificationCompletedAt: null,
    }),
    true,
  );

  assert.equal(
    shouldAutoCompleteShareReplyParentVerification({
      responseMessageId: null,
      responseText: '답변 본문',
      manualVerificationCompletedAt: null,
    }),
    true,
  );

  assert.equal(
    shouldAutoCompleteShareReplyParentVerification({
      responseMessageId: null,
      responseText: '',
      manualVerificationCompletedAt: null,
    }),
    false,
  );

  assert.equal(
    shouldAutoCompleteShareReplyParentVerification({
      responseMessageId: 102,
      responseText: '답변 본문',
      manualVerificationCompletedAt: '2026-05-24T06:00:00.000Z',
    }),
    false,
  );
});
