Chore: Fix issues with conversation data models (#1000)

Co-authored-by: Sojan <sojan@pepalo.com>
This commit is contained in:
Pranav Raj S
2020-07-04 19:46:17 +05:30
committed by GitHub
parent 36661ea45d
commit 4612494923
15 changed files with 147 additions and 51 deletions

View File

@@ -9,7 +9,7 @@ jest.mock('axios');
describe('#actions', () => {
describe('#get', () => {
it('sends correct actions if API is success', async () => {
it('sends correct mutations if API is success', async () => {
axios.get.mockResolvedValue({ data: { payload: contactList } });
await actions.get({ commit });
expect(commit.mock.calls).toEqual([
@@ -18,7 +18,7 @@ describe('#actions', () => {
[types.default.SET_CONTACT_UI_FLAG, { isFetching: false }],
]);
});
it('sends correct actions if API is error', async () => {
it('sends correct mutations if API is error', async () => {
axios.get.mockRejectedValue({ message: 'Incorrect header' });
await actions.get({ commit });
expect(commit.mock.calls).toEqual([
@@ -29,7 +29,7 @@ describe('#actions', () => {
});
describe('#show', () => {
it('sends correct actions if API is success', async () => {
it('sends correct mutations if API is success', async () => {
axios.get.mockResolvedValue({ data: { payload: contactList[0] } });
await actions.show({ commit }, { id: contactList[0].id });
expect(commit.mock.calls).toEqual([
@@ -38,7 +38,7 @@ describe('#actions', () => {
[types.default.SET_CONTACT_UI_FLAG, { isFetchingItem: false }],
]);
});
it('sends correct actions if API is error', async () => {
it('sends correct mutations if API is error', async () => {
axios.get.mockRejectedValue({ message: 'Incorrect header' });
await actions.show({ commit }, { id: contactList[0].id });
expect(commit.mock.calls).toEqual([
@@ -49,7 +49,7 @@ describe('#actions', () => {
});
describe('#update', () => {
it('sends correct actions if API is success', async () => {
it('sends correct mutations if API is success', async () => {
axios.patch.mockResolvedValue({ data: { payload: contactList[0] } });
await actions.update({ commit }, contactList[0]);
expect(commit.mock.calls).toEqual([
@@ -69,4 +69,14 @@ describe('#actions', () => {
]);
});
});
describe('#setContact', () => {
it('returns correct mutations', () => {
const data = { id: 1, name: 'john doe', availability_status: 'online' };
actions.setContact({ commit }, data);
expect(commit.mock.calls).toEqual([
[types.default.SET_CONTACT_ITEM, data],
]);
});
});
});