-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathDeleteNotification.test.ts
More file actions
30 lines (25 loc) · 1.24 KB
/
DeleteNotification.test.ts
File metadata and controls
30 lines (25 loc) · 1.24 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
28
29
30
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 notificationSubset = await getAllNotificationsByUser.execute()
const notifications = notificationSubset.notifications
const notificationId = notifications[notifications.length - 1].id
await deleteNotification.execute(notificationId)
const notificationsAfterDeleteSubset = await getAllNotificationsByUser.execute()
const notificationsAfterDelete = notificationsAfterDeleteSubset.notifications
const deletedExists = notificationsAfterDelete.some((n) => n.id === notificationId)
expect(deletedExists).toBe(false)
})
test('should throw an error when the notification id does not exist', async () => {
await expect(deleteNotification.execute(9999)).rejects.toThrow(WriteError)
})
})