summaryrefslogtreecommitdiff
path: root/spec/frontend/diffs/components
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-10-29 12:08:50 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-10-29 12:08:50 +0000
commit5a7d44a955572b912d13ba8949e976f61b5c7f1b (patch)
tree544ed48a55f80871ca0dcf588cf873ffc8ff1bc3 /spec/frontend/diffs/components
parentc3ea5eada6f28b5e46cc4114f315729cde58de87 (diff)
downloadgitlab-ce-5a7d44a955572b912d13ba8949e976f61b5c7f1b.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/diffs/components')
-rw-r--r--spec/frontend/diffs/components/collapsed_files_warning_spec.js7
-rw-r--r--spec/frontend/diffs/components/diff_file_spec.js26
2 files changed, 30 insertions, 3 deletions
diff --git a/spec/frontend/diffs/components/collapsed_files_warning_spec.js b/spec/frontend/diffs/components/collapsed_files_warning_spec.js
index 7bbffb7a1cd..fbaaf8cf5a6 100644
--- a/spec/frontend/diffs/components/collapsed_files_warning_spec.js
+++ b/spec/frontend/diffs/components/collapsed_files_warning_spec.js
@@ -3,6 +3,7 @@ import { shallowMount, mount, createLocalVue } from '@vue/test-utils';
import createStore from '~/diffs/store/modules';
import CollapsedFilesWarning from '~/diffs/components/collapsed_files_warning.vue';
import { CENTERED_LIMITED_CONTAINER_CLASSES } from '~/diffs/constants';
+import eventHub from '~/diffs/event_hub';
const propsData = {
limited: true,
@@ -76,13 +77,13 @@ describe('CollapsedFilesWarning', () => {
expect(wrapper.find('[data-testid="root"]').exists()).toBe(false);
});
- it('triggers the expandAllFiles action when the alert action button is clicked', () => {
+ it('emits the `mr:diffs:expandAllFiles` event when the alert action button is clicked', () => {
createComponent({}, { full: true });
- jest.spyOn(wrapper.vm.$store, 'dispatch').mockReturnValue(undefined);
+ jest.spyOn(eventHub, '$emit');
getAlertActionButton().vm.$emit('click');
- expect(wrapper.vm.$store.dispatch).toHaveBeenCalledWith('diffs/expandAllFiles', undefined);
+ expect(eventHub.$emit).toHaveBeenCalledWith('mr:diffs:expandAllFiles');
});
});
diff --git a/spec/frontend/diffs/components/diff_file_spec.js b/spec/frontend/diffs/components/diff_file_spec.js
index 59aa6d811ee..4a41b5b4f98 100644
--- a/spec/frontend/diffs/components/diff_file_spec.js
+++ b/spec/frontend/diffs/components/diff_file_spec.js
@@ -9,6 +9,8 @@ import DiffFileComponent from '~/diffs/components/diff_file.vue';
import DiffFileHeaderComponent from '~/diffs/components/diff_file_header.vue';
import DiffContentComponent from '~/diffs/components/diff_content.vue';
+import eventHub from '~/diffs/event_hub';
+
import { diffViewerModes, diffViewerErrors } from '~/ide/constants';
function changeViewer(store, index, { automaticallyCollapsed, manuallyCollapsed, name }) {
@@ -138,6 +140,30 @@ describe('DiffFile', () => {
});
describe('collapsing', () => {
+ describe('`mr:diffs:expandAllFiles` event', () => {
+ beforeEach(() => {
+ jest.spyOn(wrapper.vm, 'handleToggle').mockImplementation(() => {});
+ });
+
+ it('performs the normal file toggle when the file is collapsed', async () => {
+ makeFileAutomaticallyCollapsed(store);
+
+ await wrapper.vm.$nextTick();
+
+ eventHub.$emit('mr:diffs:expandAllFiles');
+
+ expect(wrapper.vm.handleToggle).toHaveBeenCalledTimes(1);
+ });
+
+ it('does nothing when the file is not collapsed', async () => {
+ eventHub.$emit('mr:diffs:expandAllFiles');
+
+ await wrapper.vm.$nextTick();
+
+ expect(wrapper.vm.handleToggle).not.toHaveBeenCalled();
+ });
+ });
+
describe('user collapsed', () => {
beforeEach(() => {
makeFileManuallyCollapsed(store);