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>2023-06-06 15:07:34 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-06-06 15:07:34 +0300
commit4958d96e262f6b31b2850123e4949536555b2d29 (patch)
tree28fe9a1fed009a569806c705e4810a33979cbd6a /spec/frontend/diffs
parent95de7177f2d5844e4aa399fea9a59d4ba6b4b1f1 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/diffs')
-rw-r--r--spec/frontend/diffs/components/diff_content_spec.js29
-rw-r--r--spec/frontend/diffs/store/actions_spec.js25
2 files changed, 49 insertions, 5 deletions
diff --git a/spec/frontend/diffs/components/diff_content_spec.js b/spec/frontend/diffs/components/diff_content_spec.js
index 3524973278c..fb271433762 100644
--- a/spec/frontend/diffs/components/diff_content_spec.js
+++ b/spec/frontend/diffs/components/diff_content_spec.js
@@ -115,6 +115,35 @@ describe('DiffContent', () => {
});
});
+ describe('with whitespace only change', () => {
+ afterEach(() => {
+ [isParallelViewGetterMock, isInlineViewGetterMock].forEach((m) => m.mockRestore());
+ });
+
+ const textDiffFile = {
+ ...defaultProps.diffFile,
+ viewer: { name: diffViewerModes.text, whitespace_only: true },
+ };
+
+ it('should render empty state', () => {
+ createComponent({
+ props: { diffFile: textDiffFile },
+ });
+
+ expect(wrapper.find('[data-testid="diff-whitespace-only-state"]').exists()).toBe(true);
+ });
+
+ it('emits load-file event when clicking show changes button', () => {
+ createComponent({
+ props: { diffFile: textDiffFile },
+ });
+
+ wrapper.find('[data-testid="diff-load-file-button"]').vm.$emit('click');
+
+ expect(wrapper.emitted('load-file')).toEqual([[{ w: '0' }]]);
+ });
+ });
+
describe('with empty files', () => {
const emptyDiffFile = {
...defaultProps.diffFile,
diff --git a/spec/frontend/diffs/store/actions_spec.js b/spec/frontend/diffs/store/actions_spec.js
index d32c2d4665d..f0061ad88d7 100644
--- a/spec/frontend/diffs/store/actions_spec.js
+++ b/spec/frontend/diffs/store/actions_spec.js
@@ -790,7 +790,7 @@ describe('DiffsStoreActions', () => {
mock.onGet(file.loadCollapsedDiffUrl).reply(HTTP_STATUS_OK, data);
return diffActions
- .loadCollapsedDiff({ commit, getters: { commitId: null }, state }, file)
+ .loadCollapsedDiff({ commit, getters: { commitId: null }, state }, { file })
.then(() => {
expect(commit).toHaveBeenCalledWith(types.ADD_COLLAPSED_DIFFS, { file, data });
});
@@ -804,13 +804,28 @@ describe('DiffsStoreActions', () => {
jest.spyOn(axios, 'get').mockReturnValue(Promise.resolve({ data: {} }));
- diffActions.loadCollapsedDiff({ commit() {}, getters, state }, file);
+ diffActions.loadCollapsedDiff({ commit() {}, getters, state }, { file });
expect(axios.get).toHaveBeenCalledWith(file.load_collapsed_diff_url, {
params: { commit_id: null, w: '0' },
});
});
+ it('should pass through params', () => {
+ const file = { load_collapsed_diff_url: '/load/collapsed/diff/url' };
+ const getters = {
+ commitId: null,
+ };
+
+ jest.spyOn(axios, 'get').mockReturnValue(Promise.resolve({ data: {} }));
+
+ diffActions.loadCollapsedDiff({ commit() {}, getters, state }, { file, params: { w: '1' } });
+
+ expect(axios.get).toHaveBeenCalledWith(file.load_collapsed_diff_url, {
+ params: { commit_id: null, w: '1' },
+ });
+ });
+
it('should fetch data with commit ID', () => {
const file = { load_collapsed_diff_url: '/load/collapsed/diff/url' };
const getters = {
@@ -819,7 +834,7 @@ describe('DiffsStoreActions', () => {
jest.spyOn(axios, 'get').mockReturnValue(Promise.resolve({ data: {} }));
- diffActions.loadCollapsedDiff({ commit() {}, getters, state }, file);
+ diffActions.loadCollapsedDiff({ commit() {}, getters, state }, { file });
expect(axios.get).toHaveBeenCalledWith(file.load_collapsed_diff_url, {
params: { commit_id: '123', w: '0' },
@@ -843,7 +858,7 @@ describe('DiffsStoreActions', () => {
});
it('fetches the data when there is no mergeRequestDiff', () => {
- diffActions.loadCollapsedDiff({ commit() {}, getters, state }, file);
+ diffActions.loadCollapsedDiff({ commit() {}, getters, state }, { file });
expect(axios.get).toHaveBeenCalledWith(file.load_collapsed_diff_url, {
params: expect.any(Object),
@@ -861,7 +876,7 @@ describe('DiffsStoreActions', () => {
diffActions.loadCollapsedDiff(
{ commit() {}, getters, state: { mergeRequestDiff: { version_path: versionPath } } },
- file,
+ { file },
);
expect(axios.get).toHaveBeenCalledWith(file.load_collapsed_diff_url, {