Rename error function.

This commit is contained in:
picklesrus 2019-09-19 13:40:09 -04:00
parent 6a45907ded
commit cdd90da423
4 changed files with 13 additions and 13 deletions

View file

@ -56,7 +56,7 @@ class EmailStep extends React.Component {
this.emailInput = emailInputRef; this.emailInput = emailInputRef;
} }
onCaptchaError () { onCaptchaError () {
this.props.onMidRegistrationError( this.props.onRegistrationError(
this.props.intl.formatMessage({ this.props.intl.formatMessage({
id: 'registation.troubleReload' id: 'registation.troubleReload'
}) })
@ -211,8 +211,8 @@ class EmailStep extends React.Component {
EmailStep.propTypes = { EmailStep.propTypes = {
intl: intlShape, intl: intlShape,
onMidRegistrationError: PropTypes.func,
onNextStep: PropTypes.func, onNextStep: PropTypes.func,
onRegistrationError: PropTypes.func,
waiting: PropTypes.bool waiting: PropTypes.bool
}; };

View file

@ -23,7 +23,7 @@ class JoinFlow extends React.Component {
super(props); super(props);
bindAll(this, [ bindAll(this, [
'handleAdvanceStep', 'handleAdvanceStep',
'handleMidRegistrationError', 'handleRegistrationError',
'handlePrepareToRegister', 'handlePrepareToRegister',
'handleRegistrationResponse', 'handleRegistrationResponse',
'handleSubmitRegistration' 'handleSubmitRegistration'
@ -35,7 +35,7 @@ class JoinFlow extends React.Component {
waiting: false waiting: false
}; };
} }
handleMidRegistrationError (message) { handleRegistrationError (message) {
if (!message) { if (!message) {
message = this.props.intl.formatMessage({ message = this.props.intl.formatMessage({
id: 'registration.generalError' id: 'registration.generalError'
@ -151,8 +151,8 @@ class JoinFlow extends React.Component {
<GenderStep onNextStep={this.handleAdvanceStep} /> <GenderStep onNextStep={this.handleAdvanceStep} />
<EmailStep <EmailStep
waiting={this.state.waiting} waiting={this.state.waiting}
onMidRegistrationError={this.handleMidRegistrationError}
onNextStep={this.handlePrepareToRegister} onNextStep={this.handlePrepareToRegister}
onRegistrationError={this.handleRegistrationError}
/> />
<WelcomeStep <WelcomeStep
email={this.state.formData.email} email={this.state.formData.email}

View file

@ -122,7 +122,7 @@ describe('EmailStep test', () => {
test('onCaptchaError calls error function with correct message', () => { test('onCaptchaError calls error function with correct message', () => {
const props = { const props = {
onMidRegistrationError: jest.fn() onRegistrationError: jest.fn()
}; };
const wrapper = shallowWithIntl( const wrapper = shallowWithIntl(
@ -132,12 +132,12 @@ describe('EmailStep test', () => {
const formikWrapper = wrapper.dive(); const formikWrapper = wrapper.dive();
formikWrapper.instance().onCaptchaError(); formikWrapper.instance().onCaptchaError();
expect(props.onMidRegistrationError).toHaveBeenCalledWith('registation.troubleReload'); expect(props.onRegistrationError).toHaveBeenCalledWith('registation.troubleReload');
}); });
test('Captcha load error calls error function', () => { test('Captcha load error calls error function', () => {
const props = { const props = {
onMidRegistrationError: jest.fn() onRegistrationError: jest.fn()
}; };
// Set this to null to force an error. // Set this to null to force an error.
global.grecaptcha = null; global.grecaptcha = null;
@ -148,7 +148,7 @@ describe('EmailStep test', () => {
const formikWrapper = wrapper.dive(); const formikWrapper = wrapper.dive();
formikWrapper.instance().onCaptchaLoad(); formikWrapper.instance().onCaptchaLoad();
expect(props.onMidRegistrationError).toHaveBeenCalledWith('registation.troubleReload'); expect(props.onRegistrationError).toHaveBeenCalledWith('registation.troubleReload');
}); });
test('validateEmail test email empty', () => { test('validateEmail test email empty', () => {

View file

@ -126,17 +126,17 @@ describe('JoinFlow', () => {
expect(joinFlowInstance.props.refreshSession).not.toHaveBeenCalled(); expect(joinFlowInstance.props.refreshSession).not.toHaveBeenCalled();
expect(joinFlowInstance.state.registrationError).toBe('registration.generalError (400)'); expect(joinFlowInstance.state.registrationError).toBe('registration.generalError (400)');
}); });
test('handleMidRegistrationError with no message ', () => { test('handleRegistrationError with no message ', () => {
const joinFlowInstance = getJoinFlowWrapper().instance(); const joinFlowInstance = getJoinFlowWrapper().instance();
joinFlowInstance.setState({}); joinFlowInstance.setState({});
joinFlowInstance.handleMidRegistrationError(); joinFlowInstance.handleRegistrationError();
expect(joinFlowInstance.state.registrationError).toBe('registration.generalError'); expect(joinFlowInstance.state.registrationError).toBe('registration.generalError');
}); });
test('handleMidRegistrationError with message ', () => { test('handleRegistrationError with message ', () => {
const joinFlowInstance = getJoinFlowWrapper().instance(); const joinFlowInstance = getJoinFlowWrapper().instance();
joinFlowInstance.setState({}); joinFlowInstance.setState({});
joinFlowInstance.handleMidRegistrationError('my message'); joinFlowInstance.handleRegistrationError('my message');
expect(joinFlowInstance.state.registrationError).toBe('my message'); expect(joinFlowInstance.state.registrationError).toBe('my message');
}); });