add tests ensuring forms pass correct value to CodeEditor fields

This commit is contained in:
Keith J. Grant 2021-03-08 11:31:03 -08:00
parent 4e55c98bc6
commit 6b2cee2f69
3 changed files with 32 additions and 0 deletions

View File

@ -74,6 +74,10 @@ describe('<SmartInventoryEdit />', () => {
wrapper.unmount();
});
test('should render CodeEditor field', () => {
expect(wrapper.find('CodeEditor').prop('value')).toEqual('---');
});
test('should fetch related instance groups on initial render', async () => {
expect(InventoriesAPI.readInstanceGroups).toHaveBeenCalledTimes(1);
});

View File

@ -94,6 +94,7 @@ describe('<InventoryForm />', () => {
1
);
expect(wrapper.find('VariablesField[label="Variables"]').length).toBe(1);
expect(wrapper.find('CodeEditor').prop('value')).toEqual('---');
});
test('should update form values', async () => {

View File

@ -79,6 +79,33 @@ describe('<NotificationTemplateForm />', () => {
).toEqual(defaultMessages);
});
test('should render custom messages fields', () => {
const wrapper = mountWithContexts(
<NotificationTemplateForm
template={{
...template,
messages: {
started: {
message: 'Started',
body: null,
},
},
}}
defaultMessages={defaultMessages}
detailUrl="/notification_templates/3/detail"
onSubmit={jest.fn()}
onCancel={jest.fn()}
/>
);
expect(
wrapper
.find('CodeEditor')
.at(0)
.prop('value')
).toEqual('Started');
});
test('should submit', async () => {
const handleSubmit = jest.fn();
const wrapper = mountWithContexts(