Ensures Variables Details renders even when no value.

When there is no value VariablesDetails will show ---.
This commit is contained in:
Alex Corey
2020-01-17 12:17:17 -05:00
parent 49d1fa82d3
commit c45b1ffca6
2 changed files with 6 additions and 5 deletions

View File

@@ -14,10 +14,6 @@ function VariablesDetail({ value, label, rows }) {
const [currentValue, setCurrentValue] = useState(value); const [currentValue, setCurrentValue] = useState(value);
const [error, setError] = useState(null); const [error, setError] = useState(null);
if (!value) {
return null;
}
return ( return (
<> <>
<DetailName <DetailName
@@ -62,7 +58,7 @@ function VariablesDetail({ value, label, rows }) {
> >
<CodeMirrorInput <CodeMirrorInput
mode={mode} mode={mode}
value={currentValue} value={currentValue || '---'} // When github issue https://github.com/ansible/awx/issues/5502 gets resolved this line of code should be revisited and refactored if possible.
readOnly readOnly
rows={rows} rows={rows}
css="margin-top: 10px" css="margin-top: 10px"

View File

@@ -40,4 +40,9 @@ describe('<VariablesDetail>', () => {
expect(input2.prop('mode')).toEqual('yaml'); expect(input2.prop('mode')).toEqual('yaml');
expect(input2.prop('value')).toEqual('foo: bar\n'); expect(input2.prop('value')).toEqual('foo: bar\n');
}); });
test('should render label and value= --- when there are no values', () => {
const wrapper = shallow(<VariablesDetail value="" label="Variables" />);
expect(wrapper.find('Styled(CodeMirrorInput)').length).toBe(1);
expect(wrapper.find('div.pf-c-form__label').text()).toBe('Variables');
});
}); });