mirror of
https://github.com/ansible/awx.git
synced 2026-03-08 21:19:26 -02:30
add value assertions to code editor tests
This commit is contained in:
@@ -10,11 +10,12 @@ describe('CodeEditor', () => {
|
|||||||
it('should trigger onChange prop', () => {
|
it('should trigger onChange prop', () => {
|
||||||
const onChange = jest.fn();
|
const onChange = jest.fn();
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
<CodeEditor value="---\n" onChange={onChange} mode="yaml" />
|
<CodeEditor value="---" onChange={onChange} mode="yaml" />
|
||||||
);
|
);
|
||||||
const aceEditor = wrapper.find('AceEditor');
|
const aceEditor = wrapper.find('AceEditor');
|
||||||
expect(aceEditor.prop('mode')).toEqual('yaml');
|
expect(aceEditor.prop('mode')).toEqual('yaml');
|
||||||
expect(aceEditor.prop('setOptions').readOnly).toEqual(false);
|
expect(aceEditor.prop('setOptions').readOnly).toEqual(false);
|
||||||
|
expect(aceEditor.prop('value')).toEqual('---');
|
||||||
aceEditor.prop('onChange')('newvalue');
|
aceEditor.prop('onChange')('newvalue');
|
||||||
expect(onChange).toHaveBeenCalledWith('newvalue');
|
expect(onChange).toHaveBeenCalledWith('newvalue');
|
||||||
});
|
});
|
||||||
@@ -22,9 +23,10 @@ describe('CodeEditor', () => {
|
|||||||
it('should render in read only mode', () => {
|
it('should render in read only mode', () => {
|
||||||
const onChange = jest.fn();
|
const onChange = jest.fn();
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
<CodeEditor value="---\n" onChange={onChange} mode="yaml" readOnly />
|
<CodeEditor value="---" onChange={onChange} mode="yaml" readOnly />
|
||||||
);
|
);
|
||||||
const aceEditor = wrapper.find('AceEditor');
|
const aceEditor = wrapper.find('AceEditor');
|
||||||
expect(aceEditor.prop('setOptions').readOnly).toEqual(true);
|
expect(aceEditor.prop('setOptions').readOnly).toEqual(true);
|
||||||
|
expect(aceEditor.prop('value')).toEqual('---');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ describe('VariablesField', () => {
|
|||||||
});
|
});
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
expect(wrapper.find('CodeEditor').prop('mode')).toEqual('javascript');
|
expect(wrapper.find('CodeEditor').prop('mode')).toEqual('javascript');
|
||||||
|
expect(wrapper.find('CodeEditor').prop('value')).toEqual('{}');
|
||||||
const buttons2 = wrapper.find('Button');
|
const buttons2 = wrapper.find('Button');
|
||||||
expect(buttons2.at(0).prop('variant')).toEqual('secondary');
|
expect(buttons2.at(0).prop('variant')).toEqual('secondary');
|
||||||
expect(buttons2.at(1).prop('variant')).toEqual('primary');
|
expect(buttons2.at(1).prop('variant')).toEqual('primary');
|
||||||
@@ -69,6 +70,7 @@ describe('VariablesField', () => {
|
|||||||
expect(field.prop('hasErrors')).toEqual(true);
|
expect(field.prop('hasErrors')).toEqual(true);
|
||||||
expect(wrapper.find('.pf-m-error')).toHaveLength(1);
|
expect(wrapper.find('.pf-m-error')).toHaveLength(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render tooltip', () => {
|
it('should render tooltip', () => {
|
||||||
const value = '---\n';
|
const value = '---\n';
|
||||||
const wrapper = mountWithContexts(
|
const wrapper = mountWithContexts(
|
||||||
|
|||||||
Reference in New Issue
Block a user