fixed tests

This commit is contained in:
Wyatt Johnson
2017-12-21 12:43:26 -07:00
parent 4fb9910221
commit c8ab5cdbf6
3 changed files with 2 additions and 24 deletions
-7
View File
@@ -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
View File
@@ -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');
+1 -16
View File
@@ -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');
}
});
});
});