mirror of
https://github.com/wassname/talk.git
synced 2026-07-20 12:40:47 +08:00
fixed tests
This commit is contained in:
@@ -165,12 +165,6 @@ const ErrPermissionUpdateUsername = new APIError('You do not have permission to
|
||||
status: 403
|
||||
});
|
||||
|
||||
// ErrSameUsernameProvided is returned when attempting to update a username to the same username.
|
||||
const ErrSameUsernameProvided = new APIError('Same username provided.', {
|
||||
translation_key: 'SAME_USERNAME_PROVIDED',
|
||||
status: 400
|
||||
});
|
||||
|
||||
// ErrLoginAttemptMaximumExceeded is returned when the login maximum is exceeded.
|
||||
const ErrLoginAttemptMaximumExceeded = new APIError('You have made too many incorrect password attempts.', {
|
||||
translation_key: 'LOGIN_MAXIMUM_EXCEEDED',
|
||||
@@ -238,7 +232,6 @@ module.exports = {
|
||||
ErrNotVerified,
|
||||
ErrPasswordTooShort,
|
||||
ErrPermissionUpdateUsername,
|
||||
ErrSameUsernameProvided,
|
||||
ErrSettingsInit,
|
||||
ErrSettingsNotInit,
|
||||
ErrSpecialChars,
|
||||
|
||||
+1
-1
@@ -282,7 +282,7 @@ class UsersService {
|
||||
}
|
||||
|
||||
if (!resetAllowed && user.username === username) {
|
||||
throw errors.ErrSameUsernameProvided;
|
||||
throw errors.ErrUsernameTaken;
|
||||
}
|
||||
|
||||
throw new Error('edit username failed for an unexpected reason');
|
||||
|
||||
@@ -278,27 +278,12 @@ describe('services.UsersService', () => {
|
||||
await UsersService[func](user.id, user.username);
|
||||
throw new Error('edit was processed successfully');
|
||||
} catch (err) {
|
||||
expect(err).have.property('translation_key', 'SAME_USERNAME_PROVIDED');
|
||||
expect(err).have.property('translation_key', 'USERNAME_IN_USE');
|
||||
}
|
||||
} else {
|
||||
await UsersService[func](user.id, user.username);
|
||||
}
|
||||
});
|
||||
|
||||
it('should refuse changing the username to one already taken', async () => {
|
||||
const user = mockUsers[0];
|
||||
const otherUser = mockUsers[1];
|
||||
|
||||
// Set the user to the desired status.
|
||||
await UsersService.setUsernameStatus(user.id, okStatus);
|
||||
|
||||
try {
|
||||
await UsersService[func](user.id, otherUser.username);
|
||||
throw new Error('edit was processed successfully');
|
||||
} catch (err) {
|
||||
expect(err).have.property('translation_key', 'USERNAME_IN_USE');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user