mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-03-25 18:13:48 -04:00
* Test * Add pretty formatting * Fix Tests * Fix Tests * Fix Tests * Fix * Add pretty formatting fix * Fix * Test * Fix tests * Clean typeckech * Add prettier check * Fix api tsconfig * Fix api tsconfig * Fix tsconfig * Fix * Fix * Prettier
34 lines
982 B
TypeScript
34 lines
982 B
TypeScript
jest.mock('shared/supabase/init')
|
|
|
|
import {AuthedUser} from 'api/helpers/endpoint'
|
|
import {markAllNotifsRead} from 'api/mark-all-notifications-read'
|
|
import {sqlMatch} from 'common/test-utils'
|
|
import * as supabaseInit from 'shared/supabase/init'
|
|
|
|
describe('markAllNotifsRead', () => {
|
|
let mockPg = {} as any
|
|
beforeEach(() => {
|
|
jest.resetAllMocks()
|
|
mockPg = {
|
|
none: jest.fn(),
|
|
}
|
|
;(supabaseInit.createSupabaseDirectClient as jest.Mock).mockReturnValue(mockPg)
|
|
})
|
|
afterEach(() => {
|
|
jest.restoreAllMocks()
|
|
})
|
|
|
|
describe('when given valid input', () => {
|
|
it('should mark all notifications as read', async () => {
|
|
const mockProps = {} as any
|
|
const mockAuth = {uid: '321'} as AuthedUser
|
|
const mockReq = {} as any
|
|
|
|
await markAllNotifsRead(mockProps, mockAuth, mockReq)
|
|
|
|
expect(mockPg.none).toBeCalledTimes(1)
|
|
expect(mockPg.none).toBeCalledWith(sqlMatch('update user_notifications'), [mockAuth.uid])
|
|
})
|
|
})
|
|
})
|