add value assertions to code editor tests

This commit is contained in:
Keith J. Grant 2021-03-04 11:03:27 -08:00
parent c975f65bbc
commit 143d41fb2a
2 changed files with 6 additions and 2 deletions

View File

@ -10,11 +10,12 @@ describe('CodeEditor', () => {
it('should trigger onChange prop', () => {
const onChange = jest.fn();
const wrapper = mount(
<CodeEditor value="---\n" onChange={onChange} mode="yaml" />
<CodeEditor value="---" onChange={onChange} mode="yaml" />
);
const aceEditor = wrapper.find('AceEditor');
expect(aceEditor.prop('mode')).toEqual('yaml');
expect(aceEditor.prop('setOptions').readOnly).toEqual(false);
expect(aceEditor.prop('value')).toEqual('---');
aceEditor.prop('onChange')('newvalue');
expect(onChange).toHaveBeenCalledWith('newvalue');
});
@ -22,9 +23,10 @@ describe('CodeEditor', () => {
it('should render in read only mode', () => {
const onChange = jest.fn();
const wrapper = mount(
<CodeEditor value="---\n" onChange={onChange} mode="yaml" readOnly />
<CodeEditor value="---" onChange={onChange} mode="yaml" readOnly />
);
const aceEditor = wrapper.find('AceEditor');
expect(aceEditor.prop('setOptions').readOnly).toEqual(true);
expect(aceEditor.prop('value')).toEqual('---');
});
});

View File

@ -40,6 +40,7 @@ describe('VariablesField', () => {
});
wrapper.update();
expect(wrapper.find('CodeEditor').prop('mode')).toEqual('javascript');
expect(wrapper.find('CodeEditor').prop('value')).toEqual('{}');
const buttons2 = wrapper.find('Button');
expect(buttons2.at(0).prop('variant')).toEqual('secondary');
expect(buttons2.at(1).prop('variant')).toEqual('primary');
@ -69,6 +70,7 @@ describe('VariablesField', () => {
expect(field.prop('hasErrors')).toEqual(true);
expect(wrapper.find('.pf-m-error')).toHaveLength(1);
});
it('should render tooltip', () => {
const value = '---\n';
const wrapper = mountWithContexts(