-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove legacy notification datasource, Add tests for notification rep…
…ository
- Loading branch information
Showing
12 changed files
with
372 additions
and
1,269 deletions.
There are no files selected for viewing
30 changes: 0 additions & 30 deletions
30
src/datasources/notifications/__tests__/test.notifications.datasource.module.ts
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
src/datasources/notifications/entities/__tests__/notification-devices.entity.db.builder.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} |
16 changes: 16 additions & 0 deletions
16
...tions/entities/__tests__/notification-subscription-notification-type.entity.db.builder.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} |
27 changes: 27 additions & 0 deletions
27
...tasources/notifications/entities/__tests__/notification-subscription.entity.db.builder.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} |
12 changes: 12 additions & 0 deletions
12
src/datasources/notifications/entities/__tests__/notification-type.entity.db.builder.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
14
src/datasources/notifications/notifications.datasource.module.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.