2019-09-04 23:32:49 -04:00
|
|
|
import React from 'react';
|
|
|
|
import {shallowWithIntl} 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';
|
|
|
|
|
|
|
|
describe('RegistrationErrorStep', () => {
|
2019-10-18 11:40:31 -04:00
|
|
|
const onSubmit = jest.fn();
|
2019-09-04 23:32:49 -04:00
|
|
|
|
2019-10-18 11:40:31 -04:00
|
|
|
const getRegistrationErrorStepWrapper = props => {
|
|
|
|
const wrapper = shallowWithIntl(
|
2019-09-04 23:32:49 -04:00
|
|
|
<RegistrationErrorStep
|
|
|
|
errorMsg={'error message'}
|
2019-10-18 11:40:31 -04:00
|
|
|
onSubmit={onSubmit}
|
|
|
|
{...props}
|
2019-09-04 23:32:49 -04:00
|
|
|
/>
|
|
|
|
);
|
2019-10-18 11:40:31 -04:00
|
|
|
return wrapper
|
|
|
|
.dive(); // unwrap injectIntl()
|
|
|
|
};
|
2019-09-04 23:32:49 -04:00
|
|
|
|
2019-10-18 11:40:31 -04:00
|
|
|
test('when canTryAgain is true, show tryAgain message', () => {
|
|
|
|
const props = {canTryAgain: true};
|
|
|
|
const joinFlowStepWrapper = getRegistrationErrorStepWrapper(props).find(JoinFlowStep);
|
2019-09-04 23:32:49 -04:00
|
|
|
expect(joinFlowStepWrapper).toHaveLength(1);
|
|
|
|
expect(joinFlowStepWrapper.props().description).toBe('error message');
|
|
|
|
expect(joinFlowStepWrapper.props().nextButton).toBe('general.tryAgain');
|
|
|
|
});
|
|
|
|
|
2019-10-18 11:40:31 -04:00
|
|
|
test('when canTryAgain is false, show startOver message', () => {
|
|
|
|
const props = {canTryAgain: false};
|
|
|
|
const joinFlowStepWrapper = getRegistrationErrorStepWrapper(props).find(JoinFlowStep);
|
|
|
|
expect(joinFlowStepWrapper).toHaveLength(1);
|
|
|
|
expect(joinFlowStepWrapper.props().description).toBe('error message');
|
|
|
|
expect(joinFlowStepWrapper.props().nextButton).toBe('general.startOver');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('when canTryAgain is missing, show startOver message', () => {
|
|
|
|
const joinFlowStepWrapper = getRegistrationErrorStepWrapper().find(JoinFlowStep);
|
|
|
|
expect(joinFlowStepWrapper).toHaveLength(1);
|
|
|
|
expect(joinFlowStepWrapper.props().description).toBe('error message');
|
|
|
|
expect(joinFlowStepWrapper.props().nextButton).toBe('general.startOver');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('when submitted, onSubmit is called', () => {
|
|
|
|
const joinFlowStepWrapper = getRegistrationErrorStepWrapper().find(JoinFlowStep);
|
2019-09-04 23:32:49 -04:00
|
|
|
joinFlowStepWrapper.props().onSubmit(new Event('event')); // eslint-disable-line no-undef
|
2019-10-18 11:40:31 -04:00
|
|
|
expect(onSubmit).toHaveBeenCalled();
|
2019-09-04 23:32:49 -04:00
|
|
|
});
|
|
|
|
});
|