Set sendAnalytics to be required and send the right props to the error step. Also add a test for the error step.

This commit is contained in:
picklesrus 2019-11-05 11:54:20 -05:00
parent e4b79c1bd2
commit 30967a3056
8 changed files with 30 additions and 4 deletions

View file

@ -167,7 +167,7 @@ class BirthDateStep extends React.Component {
BirthDateStep.propTypes = {
intl: intlShape,
onNextStep: PropTypes.func,
sendAnalytics: PropTypes.func
sendAnalytics: PropTypes.func.isRequired
};
const IntlBirthDateStep = injectIntl(BirthDateStep);

View file

@ -122,7 +122,7 @@ class CountryStep extends React.Component {
CountryStep.propTypes = {
intl: intlShape,
onNextStep: PropTypes.func,
sendAnalytics: PropTypes.func
sendAnalytics: PropTypes.func.isRequired
};
const IntlCountryStep = injectIntl(CountryStep);

View file

@ -235,8 +235,12 @@ EmailStep.propTypes = {
<<<<<<< HEAD
=======
onRegistrationError: PropTypes.func,
<<<<<<< HEAD
sendAnalytics: PropTypes.func,
>>>>>>> Add analytics logging to join flow. Adding page views for each step in the flow.
=======
sendAnalytics: PropTypes.func.isRequired,
>>>>>>> Set sendAnalytics to be required and send the right props to the error step. Also add a test for the error step.
waiting: PropTypes.bool
};

View file

@ -184,7 +184,7 @@ class GenderStep extends React.Component {
GenderStep.propTypes = {
intl: intlShape,
onNextStep: PropTypes.func,
sendAnalytics: PropTypes.func
sendAnalytics: PropTypes.func.isRequired
};
module.exports = injectIntl(GenderStep);

View file

@ -233,7 +233,12 @@ class JoinFlow extends React.Component {
{this.state.registrationError ? (
<RegistrationErrorStep
canTryAgain={this.canTryAgain()}
<<<<<<< HEAD
errorMsg={this.state.registrationError.errorMsg}
=======
errorMsg={this.state.registrationError}
sendAnalytics={this.sendAnalytics}
>>>>>>> Set sendAnalytics to be required and send the right props to the error step. Also add a test for the error step.
/* eslint-disable react/jsx-no-bind */
onSubmit={this.handleErrorNext}
/* eslint-enable react/jsx-no-bind */

View file

@ -63,12 +63,17 @@ RegistrationErrorStep.propTypes = {
canTryAgain: PropTypes.bool.isRequired,
errorMsg: PropTypes.string,
intl: intlShape,
<<<<<<< HEAD
onSubmit: PropTypes.func.isRequired,
sendAnalytics: PropTypes.func.isRequired
};
RegistrationErrorStep.defaultProps = {
canTryAgain: false
=======
onSubmit: PropTypes.func,
sendAnalytics: PropTypes.func.isRequired
>>>>>>> Set sendAnalytics to be required and send the right props to the error step. Also add a test for the error step.
};
const IntlRegistrationErrorStep = injectIntl(RegistrationErrorStep);

View file

@ -289,7 +289,7 @@ class UsernameStep extends React.Component {
UsernameStep.propTypes = {
intl: intlShape,
onNextStep: PropTypes.func,
sendAnalytics: PropTypes.func
sendAnalytics: PropTypes.func.isRequired
};
const IntlUsernameStep = injectIntl(UsernameStep);

View file

@ -1,5 +1,6 @@
import React from 'react';
import {shallowWithIntl} from '../../helpers/intl-helpers.jsx';
import {mountWithIntl} from '../../helpers/intl-helpers.jsx';
import JoinFlowStep from '../../../src/components/join-flow/join-flow-step';
import RegistrationErrorStep from '../../../src/components/join-flow/registration-error-step';
@ -21,6 +22,7 @@ describe('RegistrationErrorStep', () => {
return wrapper
.dive(); // unwrap injectIntl()
};
<<<<<<< HEAD
test('registrationError has JoinFlowStep', () => {
const props = {
@ -67,6 +69,16 @@ describe('RegistrationErrorStep', () => {
expect(errMsgElement).toHaveLength(0);
});
=======
test('logs to analytics', () => {
const analyticsFn = jest.fn();
mountWithIntl(
<RegistrationErrorStep
sendAnalytics={analyticsFn}
/>);
expect(analyticsFn).toHaveBeenCalledWith('join-error');
});
>>>>>>> Set sendAnalytics to be required and send the right props to the error step. Also add a test for the error step.
test('when canTryAgain is true, show tryAgain message', () => {
const props = {
canTryAgain: true,