(responses: unknown[][])
| 75 | import { acceptInvitation } from '@/lib/invitations/core' |
| 76 | |
| 77 | function queueWhereResponses(responses: unknown[][]) { |
| 78 | const queue = [...responses] |
| 79 | dbChainMockFns.where.mockImplementation(() => { |
| 80 | const result = queue.shift() ?? [] |
| 81 | const thenable = Promise.resolve(result) as Promise<unknown[]> & { |
| 82 | limit: ReturnType<typeof vi.fn> |
| 83 | orderBy: ReturnType<typeof vi.fn> |
| 84 | returning: ReturnType<typeof vi.fn> |
| 85 | groupBy: ReturnType<typeof vi.fn> |
| 86 | } |
| 87 | thenable.limit = vi.fn(() => Promise.resolve(result)) |
| 88 | thenable.orderBy = vi.fn(() => Promise.resolve(result)) |
| 89 | thenable.returning = vi.fn(() => Promise.resolve(result)) |
| 90 | thenable.groupBy = vi.fn(() => Promise.resolve(result)) |
| 91 | return thenable as ReturnType<typeof dbChainMockFns.where> |
| 92 | }) |
| 93 | } |
| 94 | |
| 95 | describe('acceptInvitation', () => { |
| 96 | beforeEach(() => { |
no test coverage detected