import { NotificationId } from './NotificationId';
import { NotificationDomainError } from '../errors/NotificationDomainError';

describe('NotificationId', () => {
  it('creates a valid NotificationId from a non-empty string', () => {
    const id = NotificationId.create('noti_123');

    expect(id.value).toBe('noti_123');
  });

  it('trims whitespace from the raw value', () => {
    const id = NotificationId.create('   noti_456   ');

    expect(id.value).toBe('noti_456');
  });

  it('throws NotificationDomainError for empty string', () => {
    expect(() => NotificationId.create('')).toThrow(NotificationDomainError);
    expect(() => NotificationId.create('   ')).toThrow(NotificationDomainError);

    try {
      NotificationId.create('   ');
    } catch (error) {
      if (error instanceof NotificationDomainError) {
        expect(error.kind).toBe('validation');
      }
    }
  });

  it('compares equality based on underlying value', () => {
    const a = NotificationId.create('noti_1');
    const b = NotificationId.create('noti_1');
    const c = NotificationId.create('noti_2');

    expect(a.equals(b)).toBe(true);
    expect(a.equals(c)).toBe(false);
  });
});