docs: fix createUser and test docs

this ports the fixes applied to createGroup to this method as well

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2021-11-06 11:49:26 +01:00
parent 5d6863d03c
commit 3291b43423
2 changed files with 3 additions and 2 deletions

View file

@ -52,12 +52,13 @@ describe('UsersService', () => {
.spyOn(userRepo, 'save') .spyOn(userRepo, 'save')
.mockImplementationOnce(async (user: User): Promise<User> => user); .mockImplementationOnce(async (user: User): Promise<User> => user);
}); });
it('works', async () => { it('successfully creates a user', async () => {
const user = await service.createUser(username, displayname); const user = await service.createUser(username, displayname);
expect(user.username).toEqual(username); expect(user.username).toEqual(username);
expect(user.displayName).toEqual(displayname); expect(user.displayName).toEqual(displayname);
}); });
it('fails if username is already taken', async () => { it('fails if username is already taken', async () => {
// add additional mock implementation for failure
jest.spyOn(userRepo, 'save').mockImplementationOnce(() => { jest.spyOn(userRepo, 'save').mockImplementationOnce(() => {
throw new Error(); throw new Error();
}); });

View file

@ -26,7 +26,7 @@ export class UsersService {
* @async * @async
* Create a new user with a given username and displayName * Create a new user with a given username and displayName
* @param username - the username the new user shall have * @param username - the username the new user shall have
* @param displayName - the display the new user shall have * @param displayName - the display name the new user shall have
* @return {User} the user * @return {User} the user
* @throws {AlreadyInDBError} the username is already taken. * @throws {AlreadyInDBError} the username is already taken.
*/ */