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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 21:42:06 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 21:42:06 +0300
commit6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch)
tree78be5963ec075d80116a932011d695dd33910b4e /spec/frontend/diffs/store/actions_spec.js
parent1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff)
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/frontend/diffs/store/actions_spec.js')
-rw-r--r--spec/frontend/diffs/store/actions_spec.js27
1 files changed, 21 insertions, 6 deletions
diff --git a/spec/frontend/diffs/store/actions_spec.js b/spec/frontend/diffs/store/actions_spec.js
index fc5e39357ca..5fef35d6c5b 100644
--- a/spec/frontend/diffs/store/actions_spec.js
+++ b/spec/frontend/diffs/store/actions_spec.js
@@ -1,6 +1,8 @@
import MockAdapter from 'axios-mock-adapter';
import Cookies from 'js-cookie';
import mockDiffFile from 'jest/diffs/mock_data/diff_file';
+import { useLocalStorageSpy } from 'helpers/local_storage_helper';
+import { TEST_HOST } from 'jest/helpers/test_constants';
import {
DIFF_VIEW_COOKIE_NAME,
INLINE_DIFF_VIEW_TYPE,
@@ -56,12 +58,10 @@ import testAction from '../../helpers/vuex_action_helper';
import * as utils from '~/diffs/store/utils';
import * as commonUtils from '~/lib/utils/common_utils';
import { mergeUrlParams } from '~/lib/utils/url_utility';
-import { useLocalStorageSpy } from 'helpers/local_storage_helper';
import { diffMetadata } from '../mock_data/diff_metadata';
-import createFlash from '~/flash';
-import { TEST_HOST } from 'jest/helpers/test_constants';
+import { deprecatedCreateFlash as createFlash } from '~/flash';
-jest.mock('~/flash', () => jest.fn());
+jest.mock('~/flash');
describe('DiffsStoreActions', () => {
useLocalStorageSpy();
@@ -1594,24 +1594,39 @@ describe('DiffsStoreActions', () => {
describe('setCurrentDiffFileIdFromNote', () => {
it('commits UPDATE_CURRENT_DIFF_FILE_ID', () => {
const commit = jest.fn();
+ const state = { diffFiles: [{ file_hash: '123' }] };
const rootGetters = {
getDiscussion: () => ({ diff_file: { file_hash: '123' } }),
notesById: { '1': { discussion_id: '2' } },
};
- setCurrentDiffFileIdFromNote({ commit, rootGetters }, '1');
+ setCurrentDiffFileIdFromNote({ commit, state, rootGetters }, '1');
expect(commit).toHaveBeenCalledWith(types.UPDATE_CURRENT_DIFF_FILE_ID, '123');
});
it('does not commit UPDATE_CURRENT_DIFF_FILE_ID when discussion has no diff_file', () => {
const commit = jest.fn();
+ const state = { diffFiles: [{ file_hash: '123' }] };
const rootGetters = {
getDiscussion: () => ({ id: '1' }),
notesById: { '1': { discussion_id: '2' } },
};
- setCurrentDiffFileIdFromNote({ commit, rootGetters }, '1');
+ setCurrentDiffFileIdFromNote({ commit, state, rootGetters }, '1');
+
+ expect(commit).not.toHaveBeenCalled();
+ });
+
+ it('does not commit UPDATE_CURRENT_DIFF_FILE_ID when diff file does not exist', () => {
+ const commit = jest.fn();
+ const state = { diffFiles: [{ file_hash: '123' }] };
+ const rootGetters = {
+ getDiscussion: () => ({ diff_file: { file_hash: '124' } }),
+ notesById: { '1': { discussion_id: '2' } },
+ };
+
+ setCurrentDiffFileIdFromNote({ commit, state, rootGetters }, '1');
expect(commit).not.toHaveBeenCalled();
});