Skip to content

Commit

Permalink
Feat/notifications tests (#514)
Browse files Browse the repository at this point in the history
* Feat: add notificationService tests

* Test: add Notification router tests

* Test: add integration test for notifications

* Fix: notification tests to work with new behaviour

* Chore: swap constants to SCREAMING_SNAKE_CASE

* Chore: fix test description

* Chore: add comments

* Chore: modify test names

* Fix: cleanup tables between tests
  • Loading branch information
alexanderleegs committed Jan 5, 2023
1 parent 7b74cee commit ac2a5c9
Show file tree
Hide file tree
Showing 6 changed files with 823 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/fixtures/notifications.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const CREATED_TIME = new Date()
const READ_TIME = new Date()
const OLD_READ_TIME = new Date("1995-12-17T03:24:00")

export const normalPriorityUnreadNotification = {
message: "low priority unread notification",
link: "google.com",
sourceUsername: "user",
type: "sent_request",
firstReadTime: null,
priority: 2,
createdAt: CREATED_TIME,
}

export const normalPriorityReadNotification = {
...normalPriorityUnreadNotification,
message: "low priority read notification",
firstReadTime: READ_TIME,
}

export const highPriorityUnreadNotification = {
...normalPriorityUnreadNotification,
message: "high priority unread notification",
priority: 1,
}

export const highPriorityReadNotification = {
...normalPriorityReadNotification,
message: "high priority read notification",
priority: 1,
}

export const normalPriorityOldReadNotification = {
...normalPriorityReadNotification,
message: "low priority old notification",
firstReadTime: OLD_READ_TIME,
}

export const highPriorityOldReadNotification = {
...highPriorityReadNotification,
message: "high priority old notification",
firstReadTime: OLD_READ_TIME,
}

export const formatNotification = (notification: any) => ({
message: notification.message,
createdAt: CREATED_TIME.toISOString(),
link: notification.link,
isRead: !!notification.firstReadTime,
sourceUsername: notification.sourceUsername,
type: notification.type,
})
Loading

0 comments on commit ac2a5c9

Please sign in to comment.