Commit 10b7caba authored by NataliaTepluhina's avatar NataliaTepluhina Committed by Heinrich Lee Yu

Added unit test for fetchDiscussionsBatch

parent b25c3ba2
......@@ -1407,7 +1407,7 @@ describe('Actions Notes Store', () => {
axiosMock.onAny().reply(200, { discussion });
testAction(
actions.fetchDiscussions,
true,
{},
null,
[
{ type: mutationTypes.ADD_OR_UPDATE_DISCUSSIONS, payload: { discussion } },
......@@ -1423,13 +1423,61 @@ describe('Actions Notes Store', () => {
testAction(
actions.fetchDiscussions,
true,
{ path: 'test-path', filter: 'test-filter', persistFilter: 'test-persist-filter' },
null,
[],
[
{
type: 'fetchDiscussionsBatch',
payload: { config: null, path: undefined, perPage: 20 },
payload: {
config: {
params: { notes_filter: 'test-filter', persist_filter: 'test-persist-filter' },
},
path: 'test-path',
perPage: 20,
},
},
],
done,
);
});
});
describe('fetchDiscussionsBatch', () => {
const discussion = { notes: [] };
const config = {
params: { notes_filter: 'test-filter', persist_filter: 'test-persist-filter' },
};
const actionPayload = { config, path: 'test-path', perPage: 20 };
it('updates the discussions and dispatches `updateResolvableDiscussionsCounts if there are no headers', (done) => {
axiosMock.onAny().reply(200, { discussion }, {});
testAction(
actions.fetchDiscussionsBatch,
actionPayload,
null,
[
{ type: mutationTypes.ADD_OR_UPDATE_DISCUSSIONS, payload: { discussion } },
{ type: mutationTypes.SET_FETCHING_DISCUSSIONS, payload: false },
],
[{ type: 'updateResolvableDiscussionsCounts' }],
done,
);
});
it('dispatches itself if there is `x-next-page-cursor` header', (done) => {
axiosMock.onAny().reply(200, { discussion }, { 'x-next-page-cursor': 1 });
testAction(
actions.fetchDiscussionsBatch,
actionPayload,
null,
[{ type: mutationTypes.ADD_OR_UPDATE_DISCUSSIONS, payload: { discussion } }],
[
{
type: 'fetchDiscussionsBatch',
payload: { ...actionPayload, perPage: 30, cursor: 1 },
},
],
done,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment