feat: Ability to edit a contact (#1092)

Ability to edit contact information in conversation sidebar

Co-authored-by: Sojan <sojan@pepalo.com>
This commit is contained in:
Pranav Raj S
2020-08-23 00:05:07 +05:30
committed by GitHub
parent ec6cd4bbba
commit 8cf05f1d9f
23 changed files with 709 additions and 133 deletions

View File

@@ -2,6 +2,7 @@ import axios from 'axios';
import { actions } from '../../contacts';
import * as types from '../../../mutation-types';
import contactList from './fixtures';
import { DuplicateContactException } from '../../../../../shared/helpers/CustomErrors';
const commit = jest.fn();
global.axios = axios;
@@ -68,6 +69,24 @@ describe('#actions', () => {
[types.default.SET_CONTACT_UI_FLAG, { isUpdating: false }],
]);
});
it('sends correct actions if duplicate contact is found', async () => {
axios.patch.mockRejectedValue({
response: {
data: {
message: 'Incorrect header',
contact: { id: 1, name: 'contact-name' },
},
},
});
await expect(actions.update({ commit }, contactList[0])).rejects.toThrow(
DuplicateContactException
);
expect(commit.mock.calls).toEqual([
[types.default.SET_CONTACT_UI_FLAG, { isUpdating: true }],
[types.default.SET_CONTACT_UI_FLAG, { isUpdating: false }],
]);
});
});
describe('#setContact', () => {