Commit 45a41ff4 authored by Scott Hampton's avatar Scott Hampton

Fix tests and remove extra code

According to MR suggestions, fixing tests
to account for the new polling actions. Also
removed some extra code that wasn't being
used.
parent 51cf09e6
......@@ -3,7 +3,6 @@ import Poll from '~/lib/utils/poll';
import httpStatusCodes from '~/lib/utils/http_status';
import axios from '~/lib/utils/axios_utils';
import * as types from './mutation_types';
import { s__ } from '~/locale';
let eTagPoll;
......@@ -63,18 +62,14 @@ export const fetchReport = ({ state, dispatch, commit }) => {
});
};
export const receiveReportSuccess = ({ commit }, response) => {
if (response.status === httpStatusCodes.OK) {
const report = response.data;
commit(types.RECEIVE_REPORT_SUCCESS, report);
export const receiveReportSuccess = ({ commit }, { status, data }) => {
if (status === httpStatusCodes.OK) {
commit(types.RECEIVE_REPORT_SUCCESS, data);
}
};
export const receiveReportError = ({ commit }) => {
commit(
types.RECEIVE_REPORT_ERROR,
s__('AccessibilityReport|Failed to retrieve accessibility report'),
);
commit(types.RECEIVE_REPORT_ERROR);
};
// prevent babel-plugin-rewire from generating an invalid default during karma tests
......
......@@ -12,10 +12,9 @@ export default {
state.isLoading = false;
state.report = report;
},
[types.RECEIVE_REPORT_ERROR](state, message) {
[types.RECEIVE_REPORT_ERROR](state) {
state.isLoading = false;
state.hasError = true;
state.errorMessage = message;
state.report = {};
},
};
......@@ -1063,9 +1063,6 @@ msgstr ""
msgid "AccessTokens|reset it"
msgstr ""
msgid "AccessibilityReport|Failed to retrieve accessibility report"
msgstr ""
msgid "AccessibilityReport|Learn More"
msgstr ""
......
......@@ -117,10 +117,9 @@ describe('Grouped accessibility reports app', () => {
it('renders custom accessibility issue body', () => {
const issueBody = wrapper.find(AccessibilityIssueBody);
expect(issueBody.props('issue').name).toEqual(mockReport.new_errors[0].name);
expect(issueBody.props('issue').code).toEqual(mockReport.new_errors[0].code);
expect(issueBody.props('issue').message).toEqual(mockReport.new_errors[0].message);
expect(issueBody.props('isNew')).toEqual(true);
expect(issueBody.props('issue').code).toBe(mockReport.new_errors[0].code);
expect(issueBody.props('issue').message).toBe(mockReport.new_errors[0].message);
expect(issueBody.props('isNew')).toBe(true);
});
});
});
......
......@@ -41,6 +41,8 @@ describe('Accessibility Reports actions', () => {
afterEach(() => {
mock.restore();
actions.stopPolling();
actions.clearEtagPoll();
});
describe('success', () => {
......@@ -81,7 +83,7 @@ describe('Accessibility Reports actions', () => {
});
describe('receiveReportSuccess', () => {
it('should commit RECEIVE_REPORT_SUCCESS mutation', done => {
it('should commit RECEIVE_REPORT_SUCCESS mutation with 200', done => {
testAction(
actions.receiveReportSuccess,
{ status: 200, data: mockReport },
......@@ -91,6 +93,17 @@ describe('Accessibility Reports actions', () => {
done,
);
});
it('should not commit RECEIVE_REPORTS_SUCCESS mutation with 204', done => {
testAction(
actions.receiveReportSuccess,
{ status: 204, data: mockReport },
localState,
[],
[],
done,
);
});
});
describe('receiveReportError', () => {
......@@ -99,7 +112,7 @@ describe('Accessibility Reports actions', () => {
actions.receiveReportError,
null,
localState,
[{ type: types.RECEIVE_REPORT_ERROR, payload: 'Failed to retrieve accessibility report' }],
[{ type: types.RECEIVE_REPORT_ERROR }],
[],
done,
);
......
......@@ -60,11 +60,5 @@ describe('Accessibility Reports mutations', () => {
expect(localState.hasError).toEqual(true);
});
it('sets errorMessage to given message', () => {
mutations.RECEIVE_REPORT_ERROR(localState, 'message');
expect(localState.errorMessage).toEqual('message');
});
});
});
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