import { describe, it, expect } from 'vitest';
import { isOwnMessage } from './types';
import type { Message } from './types';

const base: Message = {
  id: 'm1',
  actorId: 'actor_a',
  text: 'hello',
  at: '2026-07-17T10:00:00.000Z',
};

describe('isOwnMessage', () => {
  it('is true when the message actor matches the current actor', () => {
    expect(isOwnMessage(base, 'actor_a')).toBe(true);
  });

  it('is false when the actors differ', () => {
    expect(isOwnMessage(base, 'actor_b')).toBe(false);
  });

  it('is false when the current actor is unknown', () => {
    expect(isOwnMessage(base, null)).toBe(false);
  });

  it('is false when the message has no actor', () => {
    expect(isOwnMessage({ ...base, actorId: null }, 'actor_a')).toBe(false);
  });
});
