Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/diffs/store/actions_spec.js')
-rw-r--r--spec/frontend/diffs/store/actions_spec.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/frontend/diffs/store/actions_spec.js b/spec/frontend/diffs/store/actions_spec.js
index f46a42fae7a..1861de85ca9 100644
--- a/spec/frontend/diffs/store/actions_spec.js
+++ b/spec/frontend/diffs/store/actions_spec.js
@@ -17,6 +17,9 @@ import {
fetchDiffFilesBatch,
fetchDiffFilesMeta,
fetchCoverageFiles,
+ clearEtagPoll,
+ stopCodequalityPolling,
+ fetchCodequality,
assignDiscussionsToDiff,
removeDiscussionsFromDiff,
startRenderDiffsQueue,
@@ -98,6 +101,7 @@ describe('DiffsStoreActions', () => {
const endpointMetadata = '/diffs/set/endpoint/metadata';
const endpointBatch = '/diffs/set/endpoint/batch';
const endpointCoverage = '/diffs/set/coverage_reports';
+ const endpointCodequality = '/diffs/set/codequality_diff';
const projectPath = '/root/project';
const dismissEndpoint = '/-/user_callouts';
const showSuggestPopover = false;
@@ -109,6 +113,7 @@ describe('DiffsStoreActions', () => {
endpointBatch,
endpointMetadata,
endpointCoverage,
+ endpointCodequality,
projectPath,
dismissEndpoint,
showSuggestPopover,
@@ -118,6 +123,7 @@ describe('DiffsStoreActions', () => {
endpointBatch: '',
endpointMetadata: '',
endpointCoverage: '',
+ endpointCodequality: '',
projectPath: '',
dismissEndpoint: '',
showSuggestPopover: true,
@@ -130,6 +136,7 @@ describe('DiffsStoreActions', () => {
endpointMetadata,
endpointBatch,
endpointCoverage,
+ endpointCodequality,
projectPath,
dismissEndpoint,
showSuggestPopover,
@@ -299,6 +306,47 @@ describe('DiffsStoreActions', () => {
});
});
+ describe('fetchCodequality', () => {
+ let mock;
+ const endpointCodequality = '/fetch';
+
+ beforeEach(() => {
+ mock = new MockAdapter(axios);
+ });
+
+ afterEach(() => {
+ stopCodequalityPolling();
+ clearEtagPoll();
+ });
+
+ it('should commit SET_CODEQUALITY_DATA with received response', (done) => {
+ const data = {
+ files: { 'app.js': [{ line: 1, description: 'Unexpected alert.', severity: 'minor' }] },
+ };
+
+ mock.onGet(endpointCodequality).reply(200, { data });
+
+ testAction(
+ fetchCodequality,
+ {},
+ { endpointCodequality },
+ [{ type: types.SET_CODEQUALITY_DATA, payload: { data } }],
+ [],
+ done,
+ );
+ });
+
+ it('should show flash on API error', (done) => {
+ mock.onGet(endpointCodequality).reply(400);
+
+ testAction(fetchCodequality, {}, { endpointCodequality }, [], [], () => {
+ expect(createFlash).toHaveBeenCalledTimes(1);
+ expect(createFlash).toHaveBeenCalledWith(expect.stringMatching('Something went wrong'));
+ done();
+ });
+ });
+ });
+
describe('setHighlightedRow', () => {
it('should mark currently selected diff and set lineHash and fileHash of highlightedRow', () => {
testAction(setHighlightedRow, 'ABC_123', {}, [