fix type errors in VariablesDetail

This commit is contained in:
Keith J. Grant 2021-02-24 08:54:36 -08:00
parent d6a5a1e0d0
commit f867c9e476
3 changed files with 5 additions and 5 deletions

View File

@ -1,5 +1,5 @@
import React, { useEffect, useRef, useCallback } from 'react';
import { oneOf, bool, number, string, func } from 'prop-types';
import { oneOf, bool, number, string, func, oneOfType } from 'prop-types';
import ReactAce from 'react-ace';
import 'ace-builds/src-noconflict/mode-json';
import 'ace-builds/src-noconflict/mode-javascript';
@ -77,7 +77,7 @@ function CodeEditor({
className,
i18n,
}) {
if (typeof rows !== 'number' && rows !== 'auto') {
if (rows && typeof rows !== 'number' && rows !== 'auto') {
// eslint-disable-next-line no-console
console.warning(
`CodeEditor: Unexpected value for 'rows': ${rows}; expected number or 'auto'`
@ -186,7 +186,7 @@ CodeEditor.propTypes = {
readOnly: bool,
hasErrors: bool,
fullHeight: bool,
rows: oneOf(number, string),
rows: oneOfType([number, string]),
className: string,
};
CodeEditor.defaultProps = {

View File

@ -148,7 +148,7 @@ function VariablesDetail({ dataCy, helpText, value, label, rows, i18n }) {
VariablesDetail.propTypes = {
value: oneOfType([shape({}), arrayOf(string), string]).isRequired,
label: node.isRequired,
rows: oneOfType(number, string),
rows: oneOfType([number, string]),
dataCy: string,
helpText: string,
};

View File

@ -32,7 +32,7 @@ describe('VariablesField', () => {
</Formik>
);
const buttons = wrapper.find('Button');
expect(buttons).toHaveLength(2);
expect(buttons).toHaveLength(3);
expect(buttons.at(0).prop('variant')).toEqual('primary');
expect(buttons.at(1).prop('variant')).toEqual('secondary');
await act(async () => {