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,48 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { SubscriptionCreatedEvent } from '../events/subscription-created.event';
|
||||
import { SubscriptionUpgradedEvent } from '../events/subscription-upgraded.event';
|
||||
import { SubscriptionCancelledEvent } from '../events/subscription-cancelled.event';
|
||||
|
||||
describe('Subscription Domain Events', () => {
|
||||
describe('SubscriptionCreatedEvent', () => {
|
||||
it('creates event with correct properties', () => {
|
||||
const event = new SubscriptionCreatedEvent('sub-1', 'user-1', 'BASIC');
|
||||
|
||||
expect(event.eventName).toBe('subscription.created');
|
||||
expect(event.aggregateId).toBe('sub-1');
|
||||
expect(event.userId).toBe('user-1');
|
||||
expect(event.planTier).toBe('BASIC');
|
||||
expect(event.occurredAt).toBeInstanceOf(Date);
|
||||
});
|
||||
|
||||
it('creates event for PREMIUM tier', () => {
|
||||
const event = new SubscriptionCreatedEvent('sub-2', 'user-2', 'PREMIUM');
|
||||
expect(event.planTier).toBe('PREMIUM');
|
||||
});
|
||||
});
|
||||
|
||||
describe('SubscriptionUpgradedEvent', () => {
|
||||
it('creates event with correct properties', () => {
|
||||
const event = new SubscriptionUpgradedEvent('sub-1', 'user-1', 'BASIC', 'PREMIUM');
|
||||
|
||||
expect(event.eventName).toBe('subscription.upgraded');
|
||||
expect(event.aggregateId).toBe('sub-1');
|
||||
expect(event.userId).toBe('user-1');
|
||||
expect(event.fromTier).toBe('BASIC');
|
||||
expect(event.toTier).toBe('PREMIUM');
|
||||
expect(event.occurredAt).toBeInstanceOf(Date);
|
||||
});
|
||||
});
|
||||
|
||||
describe('SubscriptionCancelledEvent', () => {
|
||||
it('creates event with correct properties', () => {
|
||||
const event = new SubscriptionCancelledEvent('sub-1', 'user-1', 'PREMIUM');
|
||||
|
||||
expect(event.eventName).toBe('subscription.cancelled');
|
||||
expect(event.aggregateId).toBe('sub-1');
|
||||
expect(event.userId).toBe('user-1');
|
||||
expect(event.planTier).toBe('PREMIUM');
|
||||
expect(event.occurredAt).toBeInstanceOf(Date);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user