Enhancement: Upgrade @babel/preset-env (#542)

This commit is contained in:
Pranav Raj S
2020-02-22 20:16:56 +05:30
committed by GitHub
parent a790dc640f
commit 1261cc7783
7 changed files with 775 additions and 1690 deletions

View File

@@ -11,7 +11,8 @@ export default {
return m.messages.filter(
chat =>
chat.created_at * 1000 > m.agent_last_seen_at * 1000 &&
(chat.message_type === 0 && chat.private !== true)
chat.message_type === 0 &&
chat.private !== true
).length;
},
readMessages(m) {

View File

@@ -42,7 +42,8 @@ const getters = {
return chat.messages.filter(
chatMessage =>
chatMessage.created_at * 1000 > chat.agent_last_seen_at * 1000 &&
(chatMessage.message_type === 0 && chatMessage.private !== true)
chatMessage.message_type === 0 &&
chatMessage.private !== true
).length;
},
getChatStatusFilter: ({ chatStatusFilter }) => chatStatusFilter,

View File

@@ -78,13 +78,19 @@ export const actions = {
}
},
updateAutoAssignment: async ({ commit }, { id, ...inboxParams }) => {
commit(types.default.SET_INBOXES_UI_FLAG, { isUpdatingAutoAssignment: true });
commit(types.default.SET_INBOXES_UI_FLAG, {
isUpdatingAutoAssignment: true,
});
try {
const response = await InboxesAPI.update(id, inboxParams);
commit(types.default.EDIT_INBOXES, response.data);
commit(types.default.SET_INBOXES_UI_FLAG, { isUpdatingAutoAssignment: false });
commit(types.default.SET_INBOXES_UI_FLAG, {
isUpdatingAutoAssignment: false,
});
} catch (error) {
commit(types.default.SET_INBOXES_UI_FLAG, { isUpdatingAutoAssignment: false });
commit(types.default.SET_INBOXES_UI_FLAG, {
isUpdatingAutoAssignment: false,
});
throw new Error(error);
}
},

View File

@@ -91,28 +91,40 @@ describe('#actions', () => {
]);
});
});
describe('#updateAutoAssignment', () => {
it('sends correct actions if API is success', async () => {
let updatedInbox = inboxList[0];
const updatedInbox = inboxList[0];
updatedInbox.enable_auto_assignment = false;
axios.patch.mockResolvedValue({ data: updatedInbox });
await actions.updateAutoAssignment({ commit }, { id: updatedInbox.id, inbox: { enable_auto_assignment: false} });
await actions.updateAutoAssignment(
{ commit },
{ id: updatedInbox.id, inbox: { enable_auto_assignment: false } }
);
expect(commit.mock.calls).toEqual([
[types.default.SET_INBOXES_UI_FLAG, { isUpdatingAutoAssignment: true }],
[types.default.EDIT_INBOXES, updatedInbox],
[types.default.SET_INBOXES_UI_FLAG, { isUpdatingAutoAssignment: false }],
[
types.default.SET_INBOXES_UI_FLAG,
{ isUpdatingAutoAssignment: false },
],
]);
});
it('sends correct actions if API is error', async () => {
axios.patch.mockRejectedValue({ message: 'Incorrect header' });
await expect(
actions.updateAutoAssignment({ commit }, { id: inboxList[0].id, inbox: { enable_auto_assignment: false} })
actions.updateAutoAssignment(
{ commit },
{ id: inboxList[0].id, inbox: { enable_auto_assignment: false } }
)
).rejects.toThrow(Error);
expect(commit.mock.calls).toEqual([
[types.default.SET_INBOXES_UI_FLAG, { isUpdatingAutoAssignment: true }],
[types.default.SET_INBOXES_UI_FLAG, { isUpdatingAutoAssignment: false }],
[
types.default.SET_INBOXES_UI_FLAG,
{ isUpdatingAutoAssignment: false },
],
]);
});
});