Skip to content

Commit

Permalink
Remove legacy notification datasource, Add tests for notification rep…
Browse files Browse the repository at this point in the history
…ository
  • Loading branch information
PooyaRaki committed Nov 4, 2024
1 parent 36a5e58 commit 4084b74
Show file tree
Hide file tree
Showing 12 changed files with 372 additions and 1,269 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { IBuilder } from '@/__tests__/builder';
import { Builder } from '@/__tests__/builder';
import type { NotificationDevice } from '@/datasources/notifications/entities/notification-devices.entity.db';
import { DeviceType } from '@/domain/notifications/v2/entities/device-type.entity';
import { faker } from '@faker-js/faker/.';
import type { UUID } from 'crypto';

export function notificationDeviceBuilder(): IBuilder<NotificationDevice> {
return new Builder<NotificationDevice>()
.with('id', faker.number.int())
.with('device_uuid', faker.string.uuid() as UUID)
.with('device_type', faker.helpers.enumValue(DeviceType))
.with('created_at', new Date())
.with('updated_at', new Date());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { IBuilder } from '@/__tests__/builder';
import { Builder } from '@/__tests__/builder';
import { faker } from '@faker-js/faker/.';
import { notificationTypeBuilder } from '@/datasources/notifications/entities/__tests__/notification-type.entity.db.builder';
import { notificationSubscriptionBuilder } from '@/datasources/notifications/entities/__tests__/notification-subscription.entity.db.builder';
import type { NotificationSubscriptionNotificationType } from '@/datasources/notifications/entities/notification-subscription-notification-type.entity.db';

export function notificationSubscriptionNotificationTypeTypeBuilder(): IBuilder<NotificationSubscriptionNotificationType> {
return new Builder<NotificationSubscriptionNotificationType>()
.with('id', faker.number.int())
.with(
'notification_subscription',
notificationSubscriptionBuilder().build(),
)
.with('notification_type', notificationTypeBuilder().build());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { IBuilder } from '@/__tests__/builder';
import { Builder } from '@/__tests__/builder';
import { notificationDeviceBuilder } from '@/datasources/notifications/entities/__tests__/notification-devices.entity.db.builder';
import type { NotificationSubscription } from '@/datasources/notifications/entities/notification-subscription.entity.db';
import { faker } from '@faker-js/faker/.';

export function notificationSubscriptionBuilder(): IBuilder<NotificationSubscription> {
return new Builder<NotificationSubscription>()
.with('id', faker.number.int())
.with('chain_id', faker.number.int({ min: 1, max: 100 }).toString())
.with(
'safe_address',
faker.string.hexadecimal({
length: 32,
}) as `0x${string}`,
)
.with(
'signer_address',
faker.string.hexadecimal({
length: 32,
}) as `0x${string}`,
)
.with('created_at', new Date())
.with('updated_at', new Date())
.with('notification_subscription_notification_type', [])
.with('push_notification_device', notificationDeviceBuilder().build());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { IBuilder } from '@/__tests__/builder';
import { Builder } from '@/__tests__/builder';
import type { NotificationType } from '@/datasources/notifications/entities/notification-type.entity.db';
import { faker } from '@faker-js/faker/.';
import { NotificationType as NotificationTypeEnum } from '@/domain/notifications/v2/entities/notification.entity';

export function notificationTypeBuilder(): IBuilder<NotificationType> {
return new Builder<NotificationType>()
.with('id', faker.number.int())
.with('name', faker.helpers.enumValue(NotificationTypeEnum))
.with('notification_subscription_notification_type', []);
}
14 changes: 0 additions & 14 deletions src/datasources/notifications/notifications.datasource.module.ts

This file was deleted.

Loading

0 comments on commit 4084b74

Please sign in to comment.