From 143d41fb2aed41877f72df479f180580c65038fe Mon Sep 17 00:00:00 2001 From: "Keith J. Grant" Date: Thu, 4 Mar 2021 11:03:27 -0800 Subject: [PATCH] add value assertions to code editor tests --- awx/ui_next/src/components/CodeEditor/CodeEditor.test.jsx | 6 ++++-- .../src/components/CodeEditor/VariablesField.test.jsx | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/awx/ui_next/src/components/CodeEditor/CodeEditor.test.jsx b/awx/ui_next/src/components/CodeEditor/CodeEditor.test.jsx index 2da3604574..be12a6d5ee 100644 --- a/awx/ui_next/src/components/CodeEditor/CodeEditor.test.jsx +++ b/awx/ui_next/src/components/CodeEditor/CodeEditor.test.jsx @@ -10,11 +10,12 @@ describe('CodeEditor', () => { it('should trigger onChange prop', () => { const onChange = jest.fn(); const wrapper = mount( - + ); 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( - + ); const aceEditor = wrapper.find('AceEditor'); expect(aceEditor.prop('setOptions').readOnly).toEqual(true); + expect(aceEditor.prop('value')).toEqual('---'); }); }); diff --git a/awx/ui_next/src/components/CodeEditor/VariablesField.test.jsx b/awx/ui_next/src/components/CodeEditor/VariablesField.test.jsx index abbb091715..d1048ef4d1 100644 --- a/awx/ui_next/src/components/CodeEditor/VariablesField.test.jsx +++ b/awx/ui_next/src/components/CodeEditor/VariablesField.test.jsx @@ -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(