feat: Adds the ability to edit article (#5232)
This commit is contained in:
parent
b5e497a6a2
commit
b71291619c
19 changed files with 326 additions and 130 deletions
|
@ -21,6 +21,17 @@ class ArticlesAPI extends PortalsAPI {
|
|||
if (category_slug) baseUrl += `&category_slug=${category_slug}`;
|
||||
return axios.get(baseUrl);
|
||||
}
|
||||
|
||||
getArticle({ id, portalSlug }) {
|
||||
return axios.get(`${this.url}/${portalSlug}/articles/${id}`);
|
||||
}
|
||||
|
||||
updateArticle({ portalSlug, articleId, articleObj }) {
|
||||
return axios.patch(
|
||||
`${this.url}/${portalSlug}/articles/${articleId}`,
|
||||
articleObj
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default new ArticlesAPI();
|
||||
|
|
|
@ -26,4 +26,30 @@ describe('#PortalAPI', () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
describeWithAPIMock('API calls', context => {
|
||||
it('#getArticle', () => {
|
||||
articlesAPI.getArticle({
|
||||
id: 1,
|
||||
portalSlug: 'room-rental',
|
||||
});
|
||||
expect(context.axiosMock.get).toHaveBeenCalledWith(
|
||||
'/api/v1/portals/room-rental/articles/1'
|
||||
);
|
||||
});
|
||||
});
|
||||
describeWithAPIMock('API calls', context => {
|
||||
it('#updateArticle', () => {
|
||||
articlesAPI.updateArticle({
|
||||
articleId: 1,
|
||||
portalSlug: 'room-rental',
|
||||
articleObj: { title: 'Update shipping address' },
|
||||
});
|
||||
expect(context.axiosMock.patch).toHaveBeenCalledWith(
|
||||
'/api/v1/portals/room-rental/articles/1',
|
||||
{
|
||||
title: 'Update shipping address',
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue