@@ -60,8 +60,8 @@ export const actions = {
|
||||
commit(types.SET_CONTACT_UI_FLAG, { isUpdating: false });
|
||||
} catch (error) {
|
||||
commit(types.SET_CONTACT_UI_FLAG, { isUpdating: false });
|
||||
if (error.response?.data?.contact) {
|
||||
throw new DuplicateContactException(error.response.data.contact);
|
||||
if (error.response?.status === 422) {
|
||||
throw new DuplicateContactException(error.response.data.attributes);
|
||||
} else {
|
||||
throw new Error(error);
|
||||
}
|
||||
|
||||
@@ -94,9 +94,10 @@ describe('#actions', () => {
|
||||
it('sends correct actions if duplicate contact is found', async () => {
|
||||
axios.patch.mockRejectedValue({
|
||||
response: {
|
||||
status: 422,
|
||||
data: {
|
||||
message: 'Incorrect header',
|
||||
contact: { id: 1, name: 'contact-name' },
|
||||
attributes: ['email'],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user