@@ -73,7 +73,9 @@ describe('NotificationsRepository', () => {
7373 test ( 'should throw error when trying to delete notification with wrong ID' , async ( ) => {
7474 const nonExistentNotificationId = 99999
7575
76- const expectedError = new WriteError ( )
76+ const expectedError = new WriteError (
77+ `[404] Notification ${ nonExistentNotificationId } not found.`
78+ )
7779
7880 await expect ( sut . deleteNotification ( nonExistentNotificationId ) ) . rejects . toThrow ( expectedError )
7981 } )
@@ -84,18 +86,28 @@ describe('NotificationsRepository', () => {
8486 const notification = notifications [ 0 ]
8587 expect ( notification ) . toHaveProperty ( 'id' )
8688 expect ( notification ) . toHaveProperty ( 'type' )
87- expect ( notification . type ) . toBe ( NotificationType . ASSIGNROLE )
8889 expect ( notification ) . toHaveProperty ( 'sentTimestamp' )
8990 expect ( notification ) . toHaveProperty ( 'displayAsRead' )
90- expect ( notification ) . toHaveProperty ( 'dataverseDisplayName' )
91-
92- expect ( notification ) . toHaveProperty ( 'roleAssignments' )
93- expect ( notification . roleAssignments ) . toBeDefined ( )
94- expect ( notification . roleAssignments ?. length ) . toBeGreaterThan ( 0 )
95- expect ( notification . roleAssignments ?. [ 0 ] ) . toHaveProperty ( 'roleName' )
96- expect ( notification . roleAssignments ?. [ 0 ] ) . toHaveProperty ( 'assignee' )
97- expect ( notification . roleAssignments ?. [ 0 ] ) . toHaveProperty ( 'roleId' )
98- expect ( notification . roleAssignments ?. [ 0 ] ) . toHaveProperty ( 'definitionPointId' )
91+ } )
92+
93+ test ( 'should find notification with ASSIGNROLE type' , async ( ) => {
94+ const notifications : Notification [ ] = await sut . getAllNotificationsByUser ( true )
95+
96+ // Find a notification with ASSIGNROLE type
97+ const assignRoleNotification = notifications . find ( ( n ) => n . type === NotificationType . ASSIGNROLE )
98+
99+ expect ( assignRoleNotification ) . toBeDefined ( )
100+ expect ( assignRoleNotification ?. type ) . toBe ( NotificationType . ASSIGNROLE )
101+ expect ( assignRoleNotification ?. sentTimestamp ) . toBeDefined ( )
102+ expect ( assignRoleNotification ?. displayAsRead ) . toBeDefined ( )
103+ expect ( assignRoleNotification ?. dataverseDisplayName ) . toBeDefined ( )
104+
105+ expect ( assignRoleNotification ?. roleAssignments ) . toBeDefined ( )
106+ expect ( assignRoleNotification ?. roleAssignments ?. length ) . toBeGreaterThan ( 0 )
107+ expect ( assignRoleNotification ?. roleAssignments ?. [ 0 ] ) . toHaveProperty ( 'roleName' )
108+ expect ( assignRoleNotification ?. roleAssignments ?. [ 0 ] ) . toHaveProperty ( 'assignee' )
109+ expect ( assignRoleNotification ?. roleAssignments ?. [ 0 ] ) . toHaveProperty ( 'roleId' )
110+ expect ( assignRoleNotification ?. roleAssignments ?. [ 0 ] ) . toHaveProperty ( 'definitionPointId' )
99111 } )
100112
101113 test ( 'should return array when inAppNotificationFormat is false' , async ( ) => {
@@ -107,7 +119,6 @@ describe('NotificationsRepository', () => {
107119 test ( 'should return unread count' , async ( ) => {
108120 const unreadCount = await sut . getUnreadCount ( )
109121
110- console . log ( 'unreadCount' , unreadCount )
111122 expect ( typeof unreadCount ) . toBe ( 'number' )
112123 expect ( unreadCount ) . toBeGreaterThanOrEqual ( 0 )
113124 } )
0 commit comments