Commit 94981308 authored by Filipa Lacerda's avatar Filipa Lacerda

Adds action spec to cover 204

parent 15511ed1
......@@ -43,7 +43,9 @@ export const fetchReports = ({ state, dispatch }) => {
},
data: state.endpoint,
method: 'getReports',
successCallback: (response) => dispatch('receiveReportsSuccess', response),
successCallback: ({ data, status }) => dispatch('receiveReportsSuccess', {
data, status,
}),
errorCallback: () => dispatch('receiveReportsError'),
});
......@@ -52,7 +54,7 @@ export const fetchReports = ({ state, dispatch }) => {
} else {
axios
.get(state.endpoint)
.then((response) => dispatch('receiveReportsSuccess', response))
.then(({ data, status }) => dispatch('receiveReportsSuccess', { data, status }))
.catch(() => dispatch('receiveReportsError'));
}
......
......@@ -58,7 +58,9 @@ describe('Reports Store Actions', () => {
describe('success', () => {
it('dispatches requestReports and receiveReportsSuccess ', done => {
mock.onGet(`${TEST_HOST}/endpoint.json`).replyOnce(200, { summary: {}, suites: [{ name: 'rspec' }] });
mock
.onGet(`${TEST_HOST}/endpoint.json`)
.replyOnce(200, { summary: {}, suites: [{ name: 'rspec' }] });
testAction(
fetchReports,
......@@ -70,7 +72,7 @@ describe('Reports Store Actions', () => {
type: 'requestReports',
},
{
payload: { summary: {}, suites: [{ name: 'rspec' }] },
payload: { data: { summary: {}, suites: [{ name: 'rspec' }] }, status: 200 },
type: 'receiveReportsSuccess',
},
],
......@@ -105,16 +107,27 @@ describe('Reports Store Actions', () => {
});
describe('receiveReportsSuccess', () => {
it('should commit RECEIVE_REPORTS_SUCCESS mutation', done => {
it('should commit RECEIVE_REPORTS_SUCCESS mutation with 200', done => {
testAction(
receiveReportsSuccess,
{ summary: {} },
{ data: { summary: {} }, status: 200 },
mockedState,
[{ type: types.RECEIVE_REPORTS_SUCCESS, payload: { summary: {} } }],
[],
done,
);
});
it('should not commit RECEIVE_REPORTS_SUCCESS mutation with 204', done => {
testAction(
receiveReportsSuccess,
{ data: { summary: {} }, status: 204 },
mockedState,
[],
[],
done,
);
});
});
describe('receiveReportsError', () => {
......@@ -155,5 +168,4 @@ describe('Reports Store Actions', () => {
);
});
});
});
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