test(api): add domain layer unit tests across all modules
Cover admin events, notifications, reviews, search VOs, listings (property, media, events, price/geo/address VOs), auth events, payment events, subscription events, and analytics events. Raises domain test coverage from ~24% to ~75%. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
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');
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user