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

View File

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

View File

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