mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-22 23:27:54 -05:00
revise registration error tests
This commit is contained in:
parent
0dfd1cf9fc
commit
6d3a379d57
1 changed files with 29 additions and 13 deletions
|
@ -4,30 +4,46 @@ import JoinFlowStep from '../../../src/components/join-flow/join-flow-step';
|
||||||
import RegistrationErrorStep from '../../../src/components/join-flow/registration-error-step';
|
import RegistrationErrorStep from '../../../src/components/join-flow/registration-error-step';
|
||||||
|
|
||||||
describe('RegistrationErrorStep', () => {
|
describe('RegistrationErrorStep', () => {
|
||||||
const onTryAgain = jest.fn();
|
const onSubmit = jest.fn();
|
||||||
let wrapper;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
const getRegistrationErrorStepWrapper = props => {
|
||||||
wrapper = shallowWithIntl(
|
const wrapper = shallowWithIntl(
|
||||||
<RegistrationErrorStep
|
<RegistrationErrorStep
|
||||||
errorMsg={'error message'}
|
errorMsg={'error message'}
|
||||||
onTryAgain={onTryAgain}
|
onSubmit={onSubmit}
|
||||||
|
{...props}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
});
|
return wrapper
|
||||||
|
.dive(); // unwrap injectIntl()
|
||||||
|
};
|
||||||
|
|
||||||
test('shows JoinFlowStep with props', () => {
|
test('when canTryAgain is true, show tryAgain message', () => {
|
||||||
// Dive to get past the anonymous component.
|
const props = {canTryAgain: true};
|
||||||
const joinFlowStepWrapper = wrapper.dive().find(JoinFlowStep);
|
const joinFlowStepWrapper = getRegistrationErrorStepWrapper(props).find(JoinFlowStep);
|
||||||
expect(joinFlowStepWrapper).toHaveLength(1);
|
expect(joinFlowStepWrapper).toHaveLength(1);
|
||||||
expect(joinFlowStepWrapper.props().description).toBe('error message');
|
expect(joinFlowStepWrapper.props().description).toBe('error message');
|
||||||
expect(joinFlowStepWrapper.props().nextButton).toBe('general.tryAgain');
|
expect(joinFlowStepWrapper.props().nextButton).toBe('general.tryAgain');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('when submitted, onTryAgain is called', () => {
|
test('when canTryAgain is false, show startOver message', () => {
|
||||||
// Dive to get past the anonymous component.
|
const props = {canTryAgain: false};
|
||||||
const joinFlowStepWrapper = wrapper.dive().find(JoinFlowStep);
|
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);
|
||||||
joinFlowStepWrapper.props().onSubmit(new Event('event')); // eslint-disable-line no-undef
|
joinFlowStepWrapper.props().onSubmit(new Event('event')); // eslint-disable-line no-undef
|
||||||
expect(onTryAgain).toHaveBeenCalled();
|
expect(onSubmit).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue