import { describe, it, expect } from 'vitest';
import { NotificationSentEvent } from '../events/notification-sent.event';
import { NotificationChannel, ALL_CHANNELS } from '../value-objects/notification-channel.vo';

describe('Notifications Domain', () => {
  describe('NotificationSentEvent', () => {
    it('creates event with correct properties', () => {
      const event = new NotificationSentEvent(
        'notif-1',
        'user-1',
        NotificationChannel.EMAIL,
        'listing_approved',
      );

      expect(event.eventName).toBe('notification.sent');
      expect(event.aggregateId).toBe('notif-1');
      expect(event.userId).toBe('user-1');
      expect(event.channel).toBe('EMAIL');
      expect(event.templateKey).toBe('listing_approved');
      expect(event.occurredAt).toBeInstanceOf(Date);
    });

    it('creates event for PUSH channel', () => {
      const event = new NotificationSentEvent(
        'notif-2',
        'user-2',
        NotificationChannel.PUSH,
        'payment_received',
      );

      expect(event.channel).toBe('PUSH');
    });

    it('creates event for SMS channel', () => {
      const event = new NotificationSentEvent(
        'notif-3',
        'user-3',
        NotificationChannel.SMS,
        'kyc_approved',
      );

      expect(event.channel).toBe('SMS');
    });
  });

  describe('NotificationChannel', () => {
    it('defines all expected channels', () => {
      expect(NotificationChannel.EMAIL).toBe('EMAIL');
      expect(NotificationChannel.SMS).toBe('SMS');
      expect(NotificationChannel.PUSH).toBe('PUSH');
      expect(NotificationChannel.ZALO_OA).toBe('ZALO_OA');
    });

    it('ALL_CHANNELS contains all channel types', () => {
      expect(ALL_CHANNELS).toHaveLength(4);
      expect(ALL_CHANNELS).toContain('EMAIL');
      expect(ALL_CHANNELS).toContain('SMS');
      expect(ALL_CHANNELS).toContain('PUSH');
      expect(ALL_CHANNELS).toContain('ZALO_OA');
    });
  });
});
