/**
 * Comments module unit tests — validates schema parsing.
 */

import { describe, it, expect } from 'vitest';
import { CreateCommentSchema, UpdateCommentSchema } from './types.js';

describe('CreateCommentSchema', () => {
  it('accepts valid comment', () => {
    const result = CreateCommentSchema.safeParse({ body: 'This is a comment' });
    expect(result.success).toBe(true);
  });

  it('rejects empty body', () => {
    const result = CreateCommentSchema.safeParse({ body: '' });
    expect(result.success).toBe(false);
  });

  it('rejects missing body', () => {
    const result = CreateCommentSchema.safeParse({});
    expect(result.success).toBe(false);
  });

  it('rejects body exceeding 10000 chars', () => {
    const result = CreateCommentSchema.safeParse({ body: 'a'.repeat(10001) });
    expect(result.success).toBe(false);
  });
});

describe('UpdateCommentSchema', () => {
  it('accepts valid update', () => {
    const result = UpdateCommentSchema.safeParse({ body: 'Updated comment' });
    expect(result.success).toBe(true);
  });

  it('rejects empty body', () => {
    const result = UpdateCommentSchema.safeParse({ body: '' });
    expect(result.success).toBe(false);
  });
});
