mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-29 06:15:29 -04:00
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:
parent
5d6863d03c
commit
3291b43423
2 changed files with 3 additions and 2 deletions
|
@ -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();
|
||||||
});
|
});
|
||||||
|
|
|
@ -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.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue