feat: Clone automation rules (#3893)
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
@@ -47,28 +47,28 @@ describe('#actions', () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
// API Work in progress
|
||||
// describe('#update', () => {
|
||||
// it('sends correct actions if API is success', async () => {
|
||||
// axios.patch.mockResolvedValue({ data: automationsList[0] });
|
||||
// await actions.update({ commit }, automationsList[0]);
|
||||
// expect(commit.mock.calls).toEqual([
|
||||
// [types.default.SET_AUTOMATION_UI_FLAG, { isUpdating: true }],
|
||||
// [types.default.EDIT_AUTOMATION, automationsList[0]],
|
||||
// [types.default.SET_AUTOMATION_UI_FLAG, { isUpdating: false }],
|
||||
// ]);
|
||||
// });
|
||||
// it('sends correct actions if API is error', async () => {
|
||||
// axios.patch.mockRejectedValue({ message: 'Incorrect header' });
|
||||
// await expect(
|
||||
// actions.update({ commit }, automationsList[0])
|
||||
// ).rejects.toThrow(Error);
|
||||
// expect(commit.mock.calls).toEqual([
|
||||
// [types.default.SET_AUTOMATION_UI_FLAG, { isUpdating: true }],
|
||||
// [types.default.SET_AUTOMATION_UI_FLAG, { isUpdating: false }],
|
||||
// ]);
|
||||
// });
|
||||
// });
|
||||
|
||||
describe('#update', () => {
|
||||
it('sends correct actions if API is success', async () => {
|
||||
axios.patch.mockResolvedValue({ data: automationsList[0] });
|
||||
await actions.update({ commit }, automationsList[0]);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_AUTOMATION_UI_FLAG, { isUpdating: true }],
|
||||
[types.default.EDIT_AUTOMATION, automationsList[0]],
|
||||
[types.default.SET_AUTOMATION_UI_FLAG, { isUpdating: false }],
|
||||
]);
|
||||
});
|
||||
it('sends correct actions if API is error', async () => {
|
||||
axios.patch.mockRejectedValue({ message: 'Incorrect header' });
|
||||
await expect(
|
||||
actions.update({ commit }, automationsList[0])
|
||||
).rejects.toThrow(Error);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_AUTOMATION_UI_FLAG, { isUpdating: true }],
|
||||
[types.default.SET_AUTOMATION_UI_FLAG, { isUpdating: false }],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#delete', () => {
|
||||
it('sends correct actions if API is success', async () => {
|
||||
@@ -91,4 +91,15 @@ describe('#actions', () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#clone', () => {
|
||||
it('clones the automation', async () => {
|
||||
axios.post.mockResolvedValue({ data: automationsList[0] });
|
||||
await actions.clone({ commit }, automationsList[0]);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_AUTOMATION_UI_FLAG, { isCloning: true }],
|
||||
[types.default.SET_AUTOMATION_UI_FLAG, { isCloning: false }],
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user