Commit 7ead9d0e authored by Ben Wheeler's avatar Ben Wheeler

use updated strings in join flow

parent ca6711e8
......@@ -69,7 +69,7 @@ class CountryStep extends React.Component {
<JoinFlowStep
description={this.props.intl.formatMessage({id: 'registration.countryStepDescription'})}
headerImgSrc="/images/hoc/getting-started.jpg"
title={this.props.intl.formatMessage({id: 'general.joinScratch'})}
title={this.props.intl.formatMessage({id: 'registration.countryStepTitle'})}
waiting={isSubmitting}
onSubmit={handleSubmit}
>
......
......@@ -139,7 +139,7 @@ class UsernameStep extends React.Component {
default:
this.form.formsy.updateInputsWithError({
'user.username': this.props.intl.formatMessage({
id: 'registration.validationUsernameInvalid'
id: 'registration.validationUsernameNotAllowed'
})
});
return callback(false);
......
......@@ -5,11 +5,11 @@ module.exports.validateUsernameLocally = username => {
if (!username || username === '') {
return {valid: false, errMsgId: 'general.required'};
} else if (username.length < 3) {
return {valid: false, errMsgId: 'form.validationUsernameMinLength'};
return {valid: false, errMsgId: 'registration.validationUsernameMinLength'};
} else if (username.length > 20) {
return {valid: false, errMsgId: 'form.validationUsernameMaxLength'};
return {valid: false, errMsgId: 'registration.validationUsernameMaxLength'};
} else if (!/^[\w-]+$/i.test(username)) {
return {valid: false, errMsgId: 'form.validationUsernameRegexp'};
return {valid: false, errMsgId: 'registration.validationUsernameRegexp'};
}
return {valid: true};
};
......@@ -29,12 +29,12 @@ module.exports.validateUsernameRemotely = username => (
case 'username exists':
resolve({valid: false, errMsgId: 'registration.validationUsernameExists'});
break;
case 'bad username':
resolve({valid: false, errMsgId: 'registration.validationUsernameVulgar'});
case 'bad username': // i.e., vulgar
resolve({valid: false, errMsgId: 'registration.validationUsernameNotAllowed'});
break;
case 'invalid username':
default:
resolve({valid: false, errMsgId: 'registration.validationUsernameInvalid'});
resolve({valid: false, errMsgId: 'registration.validationUsernameNotAllowed'});
}
});
})
......@@ -55,8 +55,7 @@ module.exports.validatePasswordConfirm = (password, passwordConfirm) => {
if (!passwordConfirm) {
return {valid: false, errMsgId: 'general.required'};
} else if (password !== passwordConfirm) {
// TODO: add a new string for this case
return {valid: false, errMsgId: 'general.error'};
return {valid: false, errMsgId: 'registration.validationPasswordConfirmNotEquals'};
}
return {valid: true};
};
......@@ -13,15 +13,15 @@ describe('unit test lib/validate.js', () => {
response = validate.validateUsernameLocally('');
expect(response).toEqual({valid: false, errMsgId: 'general.required'});
response = validate.validateUsernameLocally('ab');
expect(response).toEqual({valid: false, errMsgId: 'form.validationUsernameMinLength'});
expect(response).toEqual({valid: false, errMsgId: 'registration.validationUsernameMinLength'});
response = validate.validateUsernameLocally('abcdefghijklmnopqrstu');
expect(response).toEqual({valid: false, errMsgId: 'form.validationUsernameMaxLength'});
expect(response).toEqual({valid: false, errMsgId: 'registration.validationUsernameMaxLength'});
response = validate.validateUsernameLocally('abc def');
expect(response).toEqual({valid: false, errMsgId: 'form.validationUsernameRegexp'});
expect(response).toEqual({valid: false, errMsgId: 'registration.validationUsernameRegexp'});
response = validate.validateUsernameLocally('abc!def');
expect(response).toEqual({valid: false, errMsgId: 'form.validationUsernameRegexp'});
expect(response).toEqual({valid: false, errMsgId: 'registration.validationUsernameRegexp'});
response = validate.validateUsernameLocally('abc😄def');
expect(response).toEqual({valid: false, errMsgId: 'form.validationUsernameRegexp'});
expect(response).toEqual({valid: false, errMsgId: 'registration.validationUsernameRegexp'});
});
test('validate password', () => {
......@@ -53,10 +53,10 @@ describe('unit test lib/validate.js', () => {
response = validate.validatePasswordConfirm('', '');
expect(response).toEqual({valid: false, errMsgId: 'general.required'});
response = validate.validatePasswordConfirm('abcdef', 'abcdefg');
expect(response).toEqual({valid: false, errMsgId: 'general.error'});
expect(response).toEqual({valid: false, errMsgId: 'registration.validationPasswordConfirmNotEquals'});
response = validate.validatePasswordConfirm('abcdef', '123456');
expect(response).toEqual({valid: false, errMsgId: 'general.error'});
expect(response).toEqual({valid: false, errMsgId: 'registration.validationPasswordConfirmNotEquals'});
response = validate.validatePasswordConfirm('', 'abcdefg');
expect(response).toEqual({valid: false, errMsgId: 'general.error'});
expect(response).toEqual({valid: false, errMsgId: 'registration.validationPasswordConfirmNotEquals'});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment