Merge pull request #3282 from benjiwheeler/join-flow-fix-tooltip-error

fix toolTip error by accepting bool as toolTip type
This commit is contained in:
Benjamin Wheeler 2019-08-27 11:44:46 -04:00 committed by GitHub
commit 6d78342e08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 7 deletions

View file

@ -53,9 +53,10 @@ const FormikInput = ({
FormikInput.propTypes = {
className: PropTypes.string,
error: PropTypes.string,
// error and toolTip can be false, in which case we ignore them
error: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
onSetRef: PropTypes.func,
toolTip: PropTypes.string,
toolTip: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
type: PropTypes.string,
validationClassName: PropTypes.string,
wrapperClassName: PropTypes.string

View file

@ -4,12 +4,12 @@ import FormikInput from '../../../src/components/formik-forms/formik-input.jsx';
import {Formik} from 'formik';
describe('FormikInput', () => {
test('No validation message without an error or a tooltip', () => {
test('No validation message with empty error, empty toolTip', () => {
const component = mountWithIntl(
<Formik>
<FormikInput
error=""
tooltip=""
toolTip=""
/>
</Formik>
);
@ -18,7 +18,21 @@ describe('FormikInput', () => {
expect(component.find('div.validation-info').exists()).toEqual(false);
});
test('No validation message with blank error or tooltip', () => {
test('No validation message with false error, false toolTip', () => {
const component = mountWithIntl(
<Formik>
<FormikInput
error={false}
toolTip={false}
/>
</Formik>
);
expect(component.find('ValidationMessage').exists()).toEqual(false);
expect(component.find('div.validation-error').exists()).toEqual(false);
expect(component.find('div.validation-info').exists()).toEqual(false);
});
test('No validation message with nonexistent error or toolTip', () => {
const component = mountWithIntl(
<Formik>
<FormikInput />
@ -42,7 +56,7 @@ describe('FormikInput', () => {
expect(component.find('div.validation-info').exists()).toEqual(false);
});
test('Tooltip shown when tooltip given', () => {
test('Tooltip shown when toolTip given', () => {
const component = mountWithIntl(
<Formik>
<FormikInput
@ -55,7 +69,7 @@ describe('FormikInput', () => {
expect(component.find('div.validation-info').exists()).toEqual(true);
});
test('If both error and tooltip messages, error takes precedence', () => {
test('If both error and toolTip messages, error takes precedence', () => {
const component = mountWithIntl(
<Formik>
<FormikInput