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-01-24 00:08:20 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-24 00:08:20 +0300
commit7e26b627ca9f79b34c91f17c2b0eb42ec5c591b0 (patch)
tree1811a237fbf254d28b61a143ceea27ecf17068b7 /spec/frontend/batch_comments/components/preview_dropdown_spec.js
parentcfc8827f6bf9573b02401b1908728da3aed96698 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/batch_comments/components/preview_dropdown_spec.js')
-rw-r--r--spec/frontend/batch_comments/components/preview_dropdown_spec.js29
1 files changed, 18 insertions, 11 deletions
diff --git a/spec/frontend/batch_comments/components/preview_dropdown_spec.js b/spec/frontend/batch_comments/components/preview_dropdown_spec.js
index 283632cb560..f86e003ab5f 100644
--- a/spec/frontend/batch_comments/components/preview_dropdown_spec.js
+++ b/spec/frontend/batch_comments/components/preview_dropdown_spec.js
@@ -1,9 +1,11 @@
import Vue, { nextTick } from 'vue';
import Vuex from 'vuex';
-import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
+import { GlDisclosureDropdown } from '@gitlab/ui';
+import { shallowMount } from '@vue/test-utils';
import { TEST_HOST } from 'helpers/test_constants';
import { visitUrl } from '~/lib/utils/url_utility';
import PreviewDropdown from '~/batch_comments/components/preview_dropdown.vue';
+import PreviewItem from '~/batch_comments/components/preview_item.vue';
jest.mock('~/lib/utils/url_utility', () => ({
visitUrl: jest.fn(),
@@ -17,6 +19,8 @@ let wrapper;
const setCurrentFileHash = jest.fn();
const scrollToDraft = jest.fn();
+const findPreviewItem = () => wrapper.findComponent(PreviewItem);
+
function factory({ viewDiffsFileByFile = false, draftsCount = 1, sortedDrafts = [] } = {}) {
const store = new Vuex.Store({
modules: {
@@ -42,16 +46,13 @@ function factory({ viewDiffsFileByFile = false, draftsCount = 1, sortedDrafts =
},
});
- wrapper = shallowMountExtended(PreviewDropdown, {
+ wrapper = shallowMount(PreviewDropdown, {
store,
+ stubs: { GlDisclosureDropdown },
});
}
describe('Batch comments preview dropdown', () => {
- afterEach(() => {
- wrapper.destroy();
- });
-
describe('clicking draft', () => {
it('toggles active file when viewDiffsFileByFile is true', async () => {
factory({
@@ -59,12 +60,15 @@ describe('Batch comments preview dropdown', () => {
sortedDrafts: [{ id: 1, file_hash: 'hash' }],
});
- wrapper.findByTestId('preview-item').vm.$emit('click');
+ findPreviewItem().vm.$emit('click');
await nextTick();
expect(setCurrentFileHash).toHaveBeenCalledWith(expect.anything(), 'hash');
- expect(scrollToDraft).toHaveBeenCalledWith(expect.anything(), { id: 1, file_hash: 'hash' });
+ expect(scrollToDraft).toHaveBeenCalledWith(
+ expect.anything(),
+ expect.objectContaining({ id: 1, file_hash: 'hash' }),
+ );
});
it('calls scrollToDraft', async () => {
@@ -73,11 +77,14 @@ describe('Batch comments preview dropdown', () => {
sortedDrafts: [{ id: 1 }],
});
- wrapper.findByTestId('preview-item').vm.$emit('click');
+ findPreviewItem().vm.$emit('click');
await nextTick();
- expect(scrollToDraft).toHaveBeenCalledWith(expect.anything(), { id: 1 });
+ expect(scrollToDraft).toHaveBeenCalledWith(
+ expect.anything(),
+ expect.objectContaining({ id: 1 }),
+ );
});
it('changes window location to navigate to commit', async () => {
@@ -86,7 +93,7 @@ describe('Batch comments preview dropdown', () => {
sortedDrafts: [{ id: 1, position: { head_sha: '1234' } }],
});
- wrapper.findByTestId('preview-item').vm.$emit('click');
+ findPreviewItem().vm.$emit('click');
await nextTick();