mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-03-25 01:51:37 -04:00
Refactor notification tests to improve assertions and add locale support
This commit is contained in:
@@ -116,10 +116,7 @@ describe('createComment', () => {
|
||||
'new_endorsement',
|
||||
)
|
||||
expect(supabaseNotifications.insertNotificationToSupabase).toBeCalledTimes(1)
|
||||
expect(supabaseNotifications.insertNotificationToSupabase).toBeCalledWith(
|
||||
expect.any(Object),
|
||||
expect.any(Object),
|
||||
)
|
||||
expect(supabaseNotifications.insertNotificationToSupabase).toBeCalledWith(expect.any(Object))
|
||||
expect(emailHelpers.sendNewEndorsementEmail).toBeCalledTimes(1)
|
||||
expect(emailHelpers.sendNewEndorsementEmail).toBeCalledWith(
|
||||
mockOnUser,
|
||||
|
||||
@@ -23,22 +23,23 @@ describe('getNotifications', () => {
|
||||
const mockProps = {
|
||||
limit: 10,
|
||||
after: 2,
|
||||
locale: 'fr',
|
||||
}
|
||||
const mockAuth = {uid: '321'} as AuthedUser
|
||||
const mockReq = {} as any
|
||||
const mockNotifications = {} as any
|
||||
const mockNotifications = [] as any
|
||||
|
||||
;(mockPg.map as jest.Mock).mockResolvedValue(mockNotifications)
|
||||
|
||||
const result = await getNotifications(mockProps, mockAuth, mockReq)
|
||||
|
||||
expect(result).toBe(mockNotifications)
|
||||
expect(result).toEqual(mockNotifications)
|
||||
expect(mockPg.map).toBeCalledTimes(1)
|
||||
expect(mockPg.map).toBeCalledWith(
|
||||
sqlMatch(
|
||||
'from user_notifications un left join notification_templates nt on un.template_id = nt.id',
|
||||
'from user_notifications un left join notification_templates nt on un.template_id = nt.id left join notification_template_translations ntt on nt.id = ntt.template_id and ntt.locale = $4',
|
||||
),
|
||||
[mockAuth.uid, mockProps.limit, mockProps.after],
|
||||
[mockAuth.uid, mockProps.limit, mockProps.after, mockProps.locale],
|
||||
expect.any(Function),
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user