Add accept invite

This commit is contained in:
rijkvanzanten
2020-10-27 16:55:49 +01:00
parent 93bdd50892
commit 9d9d04557f
3 changed files with 17 additions and 1 deletions

View File

@@ -1,5 +1,4 @@
import express from 'express';
import argon2 from 'argon2';
import asyncHandler from 'express-async-handler';
import Joi from 'joi';
import {

View File

@@ -9,4 +9,8 @@ export class UsersHandler extends ItemsHandler {
async invite(email: string | string[], role: string) {
await this.axios.post('/users/invite', { email, role });
}
async acceptInvite(token: string, password: string) {
await this.axios.post('/users/invite/accept', { token, password });
}
}

View File

@@ -42,4 +42,17 @@ describe('UsersHandler', () => {
});
});
});
describe('acceptInvite', () => {
it('Calls the /users/invite/accept endpoint', async () => {
const stub = sandbox.stub(handler.axios, 'post').resolves(Promise.resolve());
await handler.acceptInvite('abc.def.ghi', 'p455w0rd');
expect(stub).to.have.been.calledWith('/users/invite/accept', {
token: 'abc.def.ghi',
password: 'p455w0rd',
});
});
});
});