import { describe, it, expect, beforeEach, vi } from 'vitest'; import { InAppNotificationAdapter } from './InAppNotificationGateway'; import { Notification } from '@core/notifications/domain/entities/Notification'; describe('InAppNotificationAdapter', () => { let adapter: InAppNotificationAdapter; beforeEach(() => { adapter = new InAppNotificationAdapter(); vi.spyOn(console, 'log').mockImplementation(() => {}); }); const createNotification = (overrides: any = {}) => { return Notification.create({ id: 'notif-123', recipientId: 'driver-456', type: 'protest_filed', title: 'New Protest', body: 'A new protest has been filed against you.', channel: 'in_app', ...overrides, }); }; describe('send', () => { it('should return success', async () => { // Given const notification = createNotification(); // When const result = await adapter.send(notification); // Then expect(result.success).toBe(true); expect(result.channel).toBe('in_app'); expect(result.externalId).toBe('notif-123'); expect(result.attemptedAt).toBeInstanceOf(Date); }); }); describe('supportsChannel', () => { it('should return true for in_app channel', () => { expect(adapter.supportsChannel('in_app')).toBe(true); }); it('should return false for other channels', () => { expect(adapter.supportsChannel('email' as any)).toBe(false); }); }); describe('isConfigured', () => { it('should always return true', () => { expect(adapter.isConfigured()).toBe(true); }); }); });