2019-08-05 15:47:47 -04:00
|
|
|
import React from 'react';
|
|
|
|
import {mountWithIntl} from '../../helpers/intl-helpers.jsx';
|
|
|
|
import JoinFlowStep from '../../../src/components/join-flow/join-flow-step';
|
|
|
|
|
|
|
|
describe('JoinFlowStep', () => {
|
|
|
|
|
2019-08-13 09:21:57 -04:00
|
|
|
test('components exist when props present', () => {
|
2019-08-05 15:47:47 -04:00
|
|
|
const props = {
|
|
|
|
children: null,
|
|
|
|
className: 'join-flow-step-class',
|
|
|
|
description: 'description text',
|
|
|
|
headerImgSrc: '/image.png',
|
|
|
|
onSubmit: jest.fn(),
|
|
|
|
nextButton: 'some stuff',
|
|
|
|
title: 'join flow step title',
|
|
|
|
waiting: true
|
|
|
|
};
|
|
|
|
const component = mountWithIntl(
|
|
|
|
<JoinFlowStep
|
|
|
|
{...props}
|
|
|
|
/>
|
|
|
|
);
|
2019-08-16 18:23:01 -04:00
|
|
|
expect(component.find('img.join-flow-header-image').exists()).toEqual(true);
|
2019-08-05 15:47:47 -04:00
|
|
|
expect(component.find({src: props.headerImgSrc}).exists()).toEqual(true);
|
|
|
|
expect(component.find('.join-flow-inner-content').exists()).toEqual(true);
|
|
|
|
expect(component.find('.join-flow-title').exists()).toEqual(true);
|
|
|
|
expect(component.find('.join-flow-title').first()
|
|
|
|
.prop('title')).toEqual(props.title);
|
|
|
|
expect(component.find('div.join-flow-description').exists()).toEqual(true);
|
|
|
|
expect(component.find('div.join-flow-description').text()).toEqual(props.description);
|
|
|
|
expect(component.find('NextStepButton').prop('waiting')).toEqual(true);
|
|
|
|
expect(component.find('NextStepButton').prop('content')).toEqual(props.nextButton);
|
2019-08-13 09:21:57 -04:00
|
|
|
|
|
|
|
component.unmount();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('components do not exist when props not present', () => {
|
|
|
|
const component = mountWithIntl(
|
|
|
|
<JoinFlowStep />
|
|
|
|
);
|
|
|
|
|
2019-08-16 18:23:01 -04:00
|
|
|
expect(component.find('img.join-flow-header-image').exists()).toEqual(false);
|
2019-08-13 09:21:57 -04:00
|
|
|
expect(component.find('.join-flow-inner-content').exists()).toEqual(true);
|
|
|
|
expect(component.find('.join-flow-title').exists()).toEqual(false);
|
|
|
|
expect(component.find('div.join-flow-description').exists()).toEqual(false);
|
|
|
|
expect(component.find('NextStepButton').prop('waiting')).toEqual(false);
|
|
|
|
|
2019-08-05 15:47:47 -04:00
|
|
|
component.unmount();
|
|
|
|
});
|
|
|
|
|
2019-08-13 09:21:57 -04:00
|
|
|
test('clicking submit calls passed in function', () => {
|
2019-08-05 15:47:47 -04:00
|
|
|
const props = {
|
|
|
|
onSubmit: jest.fn()
|
|
|
|
};
|
|
|
|
const component = mountWithIntl(
|
|
|
|
<JoinFlowStep
|
|
|
|
{...props}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
component.find('button[type="submit"]').simulate('submit');
|
|
|
|
expect(props.onSubmit).toHaveBeenCalled();
|
|
|
|
component.unmount();
|
|
|
|
});
|
|
|
|
});
|