-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathDeleteNotification.test.ts
More file actions
27 lines (22 loc) · 1.04 KB
/
Copy pathDeleteNotification.test.ts
File metadata and controls
27 lines (22 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { ApiConfig, deleteNotification, getAllNotificationsByUser, WriteError } from '../../../src'
import { TestConstants } from '../../testHelpers/TestConstants'
import { DataverseApiAuthMechanism } from '../../../src/core/infra/repositories/ApiConfig'
describe('execute', () => {
beforeEach(async () => {
ApiConfig.init(
TestConstants.TEST_API_URL,
DataverseApiAuthMechanism.API_KEY,
process.env.TEST_API_KEY
)
})
test('should successfully delete a notification for authenticated user', async () => {
const notifications = await getAllNotificationsByUser.execute()
const notificationId = notifications[notifications.length - 1].id
await deleteNotification.execute(notificationId)
const notificationsAfterDelete = await getAllNotificationsByUser.execute()
expect(notificationsAfterDelete.length).toBe(notifications.length - 1)
})
test('should throw an error when the notification id does not exist', async () => {
await expect(deleteNotification.execute(123)).rejects.toThrow(WriteError)
})
})