chore: Add inbox id in get campaigns API (#2278)

This commit is contained in:
Muhsin Keloth
2021-05-17 21:38:12 +05:30
committed by GitHub
parent 60177ef418
commit 18cea3b0ac
6 changed files with 31 additions and 7 deletions

View File

@@ -1,6 +1,7 @@
import * as MutationHelpers from 'shared/helpers/vuex/mutationHelpers';
import types from '../mutation-types';
import CampaignsAPI from '../../api/campaigns';
import InboxesAPI from '../../api/inboxes';
export const state = {
records: [],
@@ -20,10 +21,10 @@ export const getters = {
};
export const actions = {
get: async function getCampaigns({ commit }) {
get: async function getCampaigns({ commit }, { inboxId }) {
commit(types.SET_CAMPAIGN_UI_FLAG, { isFetching: true });
try {
const response = await CampaignsAPI.get();
const response = await InboxesAPI.getCampaigns(inboxId);
commit(types.SET_CAMPAIGNS, response.data);
} catch (error) {
// Ignore error

View File

@@ -11,7 +11,7 @@ describe('#actions', () => {
describe('#get', () => {
it('sends correct actions if API is success', async () => {
axios.get.mockResolvedValue({ data: campaignList });
await actions.get({ commit });
await actions.get({ commit }, { inboxId: 23 });
expect(commit.mock.calls).toEqual([
[types.default.SET_CAMPAIGN_UI_FLAG, { isFetching: true }],
[types.default.SET_CAMPAIGNS, campaignList],
@@ -20,7 +20,7 @@ describe('#actions', () => {
});
it('sends correct actions if API is error', async () => {
axios.get.mockRejectedValue({ message: 'Incorrect header' });
await actions.get({ commit });
await actions.get({ commit }, { inboxId: 23 });
expect(commit.mock.calls).toEqual([
[types.default.SET_CAMPAIGN_UI_FLAG, { isFetching: true }],
[types.default.SET_CAMPAIGN_UI_FLAG, { isFetching: false }],