feat: Adds the ability to edit article (#5232)

This commit is contained in:
Muhsin Keloth
2022-08-16 17:55:34 +05:30
committed by GitHub
parent b5e497a6a2
commit b71291619c
19 changed files with 326 additions and 130 deletions

View File

@@ -89,8 +89,15 @@ describe('#actions', () => {
describe('#update', () => {
it('sends correct actions if API is success', async () => {
axios.patch.mockResolvedValue({ data: articleList[0] });
await actions.update({ commit }, articleList[0]);
axios.patch.mockResolvedValue({ data: { payload: articleList[0] } });
await actions.update(
{ commit },
{
portalSlug: 'room-rental',
articleId: 1,
title: 'Documents are required to complete KYC',
}
);
expect(commit.mock.calls).toEqual([
[
types.default.ADD_ARTICLE_FLAG,
@@ -105,9 +112,17 @@ describe('#actions', () => {
});
it('sends correct actions if API is error', async () => {
axios.patch.mockRejectedValue({ message: 'Incorrect header' });
await expect(actions.update({ commit }, articleList[0])).rejects.toThrow(
Error
);
await expect(
actions.update(
{ commit },
{
portalSlug: 'room-rental',
articleId: 1,
title: 'Documents are required to complete KYC',
}
)
).rejects.toThrow(Error);
expect(commit.mock.calls).toEqual([
[
types.default.ADD_ARTICLE_FLAG,