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/javascripts/diffs/store/actions_spec.js')
-rw-r--r--spec/javascripts/diffs/store/actions_spec.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/javascripts/diffs/store/actions_spec.js b/spec/javascripts/diffs/store/actions_spec.js
index ff17d8ec158..7363a213847 100644
--- a/spec/javascripts/diffs/store/actions_spec.js
+++ b/spec/javascripts/diffs/store/actions_spec.js
@@ -12,6 +12,7 @@ import actions, {
fetchDiffFiles,
fetchDiffFilesBatch,
fetchDiffFilesMeta,
+ fetchCoverageFiles,
assignDiscussionsToDiff,
removeDiscussionsFromDiff,
startRenderDiffsQueue,
@@ -73,6 +74,7 @@ describe('DiffsStoreActions', () => {
const endpoint = '/diffs/set/endpoint';
const endpointMetadata = '/diffs/set/endpoint/metadata';
const endpointBatch = '/diffs/set/endpoint/batch';
+ const endpointCoverage = '/diffs/set/coverage_reports';
const projectPath = '/root/project';
const dismissEndpoint = '/-/user_callouts';
const showSuggestPopover = false;
@@ -84,6 +86,7 @@ describe('DiffsStoreActions', () => {
endpoint,
endpointBatch,
endpointMetadata,
+ endpointCoverage,
projectPath,
dismissEndpoint,
showSuggestPopover,
@@ -93,6 +96,7 @@ describe('DiffsStoreActions', () => {
endpoint: '',
endpointBatch: '',
endpointMetadata: '',
+ endpointCoverage: '',
projectPath: '',
dismissEndpoint: '',
showSuggestPopover: true,
@@ -105,6 +109,7 @@ describe('DiffsStoreActions', () => {
endpoint,
endpointMetadata,
endpointBatch,
+ endpointCoverage,
projectPath,
dismissEndpoint,
showSuggestPopover,
@@ -318,6 +323,44 @@ describe('DiffsStoreActions', () => {
});
});
+ describe('fetchCoverageFiles', () => {
+ let mock;
+ const endpointCoverage = '/fetch';
+
+ beforeEach(() => {
+ mock = new MockAdapter(axios);
+ });
+
+ afterEach(() => mock.restore());
+
+ it('should commit SET_COVERAGE_DATA with received response', done => {
+ const data = { files: { 'app.js': { '1': 0, '2': 1 } } };
+
+ mock.onGet(endpointCoverage).reply(200, { data });
+
+ testAction(
+ fetchCoverageFiles,
+ {},
+ { endpointCoverage },
+ [{ type: types.SET_COVERAGE_DATA, payload: { data } }],
+ [],
+ done,
+ );
+ });
+
+ it('should show flash on API error', done => {
+ const flashSpy = spyOnDependency(actions, 'createFlash');
+
+ mock.onGet(endpointCoverage).reply(400);
+
+ testAction(fetchCoverageFiles, {}, { endpointCoverage }, [], [], () => {
+ expect(flashSpy).toHaveBeenCalledTimes(1);
+ expect(flashSpy).toHaveBeenCalledWith(jasmine.stringMatching('Something went wrong'));
+ done();
+ });
+ });
+ });
+
describe('setHighlightedRow', () => {
it('should mark currently selected diff and set lineHash and fileHash of highlightedRow', () => {
testAction(setHighlightedRow, 'ABC_123', {}, [