refactor use cases
This commit is contained in:
@@ -1,28 +1,27 @@
|
||||
import { describe, it, expect, vi, type Mock } from 'vitest';
|
||||
import {
|
||||
GetNotificationPreferencesQuery,
|
||||
UpdateChannelPreferenceUseCase,
|
||||
UpdateTypePreferenceUseCase,
|
||||
UpdateQuietHoursUseCase,
|
||||
SetDigestModeUseCase,
|
||||
type GetNotificationPreferencesInput,
|
||||
type GetNotificationPreferencesResult,
|
||||
type UpdateChannelPreferenceCommand,
|
||||
type UpdateChannelPreferenceResult,
|
||||
type UpdateTypePreferenceCommand,
|
||||
type UpdateTypePreferenceResult,
|
||||
type UpdateQuietHoursCommand,
|
||||
type UpdateQuietHoursResult,
|
||||
type SetDigestModeCommand,
|
||||
type SetDigestModeResult,
|
||||
} from './NotificationPreferencesUseCases';
|
||||
import type { INotificationPreferenceRepository } from '../../domain/repositories/INotificationPreferenceRepository';
|
||||
import type { NotificationPreference , ChannelPreference, TypePreference } from '../../domain/entities/NotificationPreference';
|
||||
import type { Logger, UseCaseOutputPort } from '@core/shared/application';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
import { describe, expect, it, vi, type Mock } from 'vitest';
|
||||
import type { ChannelPreference, NotificationPreference, TypePreference } from '../../domain/entities/NotificationPreference';
|
||||
import type { INotificationPreferenceRepository } from '../../domain/repositories/INotificationPreferenceRepository';
|
||||
import type { NotificationChannel, NotificationType } from '../../domain/types/NotificationTypes';
|
||||
import { NotificationDomainError } from '../../domain/errors/NotificationDomainError';
|
||||
import {
|
||||
GetNotificationPreferencesQuery,
|
||||
SetDigestModeUseCase,
|
||||
UpdateChannelPreferenceUseCase,
|
||||
UpdateQuietHoursUseCase,
|
||||
UpdateTypePreferenceUseCase,
|
||||
type GetNotificationPreferencesInput,
|
||||
type GetNotificationPreferencesResult,
|
||||
type SetDigestModeCommand,
|
||||
type SetDigestModeResult,
|
||||
type UpdateChannelPreferenceCommand,
|
||||
type UpdateChannelPreferenceResult,
|
||||
type UpdateQuietHoursCommand,
|
||||
type UpdateQuietHoursResult,
|
||||
type UpdateTypePreferenceCommand,
|
||||
type UpdateTypePreferenceResult,
|
||||
} from './NotificationPreferencesUseCases';
|
||||
|
||||
describe('NotificationPreferencesUseCases', () => {
|
||||
let preferenceRepository: {
|
||||
|
||||
@@ -81,13 +81,15 @@ export class SendNotificationUseCase {
|
||||
...(command.data ? { data: command.data } : {}),
|
||||
...(command.actionUrl ? { actionUrl: command.actionUrl } : {}),
|
||||
});
|
||||
|
||||
|
||||
await this.notificationRepository.create(notification);
|
||||
|
||||
return {
|
||||
|
||||
this.output.present({
|
||||
notification,
|
||||
deliveryResults: [],
|
||||
};
|
||||
});
|
||||
|
||||
return Result.ok(undefined);
|
||||
}
|
||||
|
||||
// Determine which channels to use
|
||||
|
||||
Reference in New Issue
Block a user