Fixes for invitation unit tests
This commit is contained in:
parent
f66fc22f29
commit
09adef4d59
|
@ -254,7 +254,7 @@ export const onboardUsers = async (ctx: any) => {
|
|||
onboardingResponse = await userSdk.bulkCreate(assignUsers, groups)
|
||||
ctx.body = onboardingResponse
|
||||
} else if (emailConfigured) {
|
||||
onboardingResponse = await invite(ctx)
|
||||
onboardingResponse = await inviteMultiple(ctx)
|
||||
} else if (!emailConfigured) {
|
||||
const inviteRequest = ctx.request.body as InviteUsersRequest
|
||||
|
||||
|
@ -297,8 +297,10 @@ export const onboardUsers = async (ctx: any) => {
|
|||
}
|
||||
|
||||
export const invite = async (ctx: any) => {
|
||||
const request = ctx.request.body as InviteUsersRequest
|
||||
const response = await userSdk.invite(request)
|
||||
const request = ctx.request.body as InviteUserRequest
|
||||
|
||||
let multiRequest = [request] as InviteUsersRequest
|
||||
const response = await userSdk.invite(multiRequest)
|
||||
|
||||
// explicitly throw for single user invite
|
||||
if (response.unsuccessful.length) {
|
||||
|
|
|
@ -30,7 +30,11 @@ describe("/api/global/users", () => {
|
|||
email
|
||||
)
|
||||
|
||||
expect(res.body).toEqual({ message: "Invitation has been sent." })
|
||||
expect(res.body?.message).toBe("Invitation has been sent.")
|
||||
expect(res.body?.unsuccessful.length).toBe(0)
|
||||
expect(res.body?.successful.length).toBe(1)
|
||||
expect(res.body?.successful[0].email).toBe(email)
|
||||
|
||||
expect(sendMailMock).toHaveBeenCalled()
|
||||
expect(code).toBeDefined()
|
||||
expect(events.user.invited).toBeCalledTimes(1)
|
||||
|
|
Loading…
Reference in New Issue