|
@@ -1,14 +1,14 @@
|
|
|
import { TimerInterface } from '@standardnotes/time'
|
|
|
-import { Result } from '@standardnotes/domain-core'
|
|
|
+import { NotificationPayload, NotificationType, Result, Uuid } from '@standardnotes/domain-core'
|
|
|
|
|
|
import { NotificationRepositoryInterface } from '../../../Notifications/NotificationRepositoryInterface'
|
|
|
import { Notification } from '../../../Notifications/Notification'
|
|
|
import { AddNotificationForUser } from './AddNotificationForUser'
|
|
|
-import { NotificationType } from '../../../Notifications/NotificationType'
|
|
|
|
|
|
describe('AddNotificationForUser', () => {
|
|
|
let notificationRepository: NotificationRepositoryInterface
|
|
|
let timer: TimerInterface
|
|
|
+ let payload: NotificationPayload
|
|
|
|
|
|
const createUseCase = () => new AddNotificationForUser(notificationRepository, timer)
|
|
|
|
|
@@ -18,6 +18,12 @@ describe('AddNotificationForUser', () => {
|
|
|
|
|
|
timer = {} as jest.Mocked<TimerInterface>
|
|
|
timer.getTimestampInMicroseconds = jest.fn().mockReturnValue(123456789)
|
|
|
+
|
|
|
+ payload = NotificationPayload.create({
|
|
|
+ sharedVaultUuid: Uuid.create('0e8c3c7e-3f1a-4f7a-9b5a-5b2b0a7d4b1e').getValue(),
|
|
|
+ type: NotificationType.create(NotificationType.TYPES.RemovedFromSharedVault).getValue(),
|
|
|
+ version: '1.0',
|
|
|
+ }).getValue()
|
|
|
})
|
|
|
|
|
|
it('should save notification', async () => {
|
|
@@ -26,7 +32,7 @@ describe('AddNotificationForUser', () => {
|
|
|
const result = await useCase.execute({
|
|
|
userUuid: '0e8c3c7e-3f1a-4f7a-9b5a-5b2b0a7d4b1e',
|
|
|
type: NotificationType.TYPES.RemovedFromSharedVault,
|
|
|
- payload: 'payload',
|
|
|
+ payload,
|
|
|
version: '1.0',
|
|
|
})
|
|
|
|
|
@@ -39,7 +45,7 @@ describe('AddNotificationForUser', () => {
|
|
|
const result = await useCase.execute({
|
|
|
userUuid: 'invalid',
|
|
|
type: NotificationType.TYPES.RemovedFromSharedVault,
|
|
|
- payload: 'payload',
|
|
|
+ payload,
|
|
|
version: '1.0',
|
|
|
})
|
|
|
|
|
@@ -52,20 +58,7 @@ describe('AddNotificationForUser', () => {
|
|
|
const result = await useCase.execute({
|
|
|
userUuid: '0e8c3c7e-3f1a-4f7a-9b5a-5b2b0a7d4b1e',
|
|
|
type: 'invalid',
|
|
|
- payload: 'payload',
|
|
|
- version: '1.0',
|
|
|
- })
|
|
|
-
|
|
|
- expect(result.isFailed()).toBeTruthy()
|
|
|
- })
|
|
|
-
|
|
|
- it('should return error if notification payload is invalid', async () => {
|
|
|
- const useCase = createUseCase()
|
|
|
-
|
|
|
- const result = await useCase.execute({
|
|
|
- userUuid: '0e8c3c7e-3f1a-4f7a-9b5a-5b2b0a7d4b1e',
|
|
|
- type: NotificationType.TYPES.RemovedFromSharedVault,
|
|
|
- payload: '',
|
|
|
+ payload,
|
|
|
version: '1.0',
|
|
|
})
|
|
|
|
|
@@ -83,7 +76,7 @@ describe('AddNotificationForUser', () => {
|
|
|
const result = await useCase.execute({
|
|
|
userUuid: '0e8c3c7e-3f1a-4f7a-9b5a-5b2b0a7d4b1e',
|
|
|
type: NotificationType.TYPES.RemovedFromSharedVault,
|
|
|
- payload: 'payload',
|
|
|
+ payload,
|
|
|
version: '1.0',
|
|
|
})
|
|
|
|