Updates tests to a real error.

This commit is contained in:
Alex Corey 2020-03-03 11:56:52 -05:00
parent b055aad641
commit 4709f57f46
2 changed files with 36 additions and 20 deletions

View File

@ -83,7 +83,16 @@ describe('<WorkflowJobTemplateAdd/>', () => {
});
test('throwing error renders FormSubmitError component', async () => {
const error = new Error('oops');
const error = {
response: {
config: {
method: 'post',
url: '/api/v2/workflow_job_templates/',
},
data: { detail: 'An error occurred' },
},
};
WorkflowJobTemplatesAPI.create.mockRejectedValue(error);
await act(async () => {
wrapper.find('WorkflowJobTemplateForm').invoke('handleSubmit')({
@ -98,16 +107,15 @@ describe('<WorkflowJobTemplateAdd/>', () => {
});
test('throwing error prevents navigation away from form', async () => {
OrganizationsAPI.read.mockRejectedValue(
new Error({
response: {
config: {
method: 'get',
},
data: 'An error occurred',
OrganizationsAPI.read.mockRejectedValue({
response: {
config: {
method: 'get',
url: '/api/v2/organizations/',
},
})
);
data: 'An error occurred',
},
});
WorkflowJobTemplatesAPI.update.mockResolvedValue();
await act(async () => {

View File

@ -114,7 +114,15 @@ describe('<WorkflowJobTemplateEdit/>', () => {
});
test('throwing error renders FormSubmitError component', async () => {
const error = new Error('oops');
const error = {
response: {
config: {
method: 'patch',
url: '/api/v2/workflow_job_templates/',
},
data: { detail: 'An error occurred' },
},
};
WorkflowJobTemplatesAPI.update.mockRejectedValue(error);
await act(async () => {
wrapper.find('Button[aria-label="Save"]').simulate('click');
@ -155,16 +163,16 @@ describe('<WorkflowJobTemplateEdit/>', () => {
}
);
});
OrganizationsAPI.read.mockRejectedValue(
new Error({
response: {
config: {
method: 'get',
},
data: 'An error occurred',
OrganizationsAPI.read.mockRejectedValue({
response: {
config: {
method: 'get',
url: '/api/v2/organizations/',
},
})
);
data: { detail: 'An error occurred' },
},
});
WorkflowJobTemplatesAPI.update.mockResolvedValue();
await act(async () => {