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>2022-11-23 18:07:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-11-23 18:07:42 +0300
commitbc0f141f2f073a971aad1eb5349bb718747df028 (patch)
tree72fcc48dfac8e3f3560e22014eacdd2eaae8bc89 /spec/frontend/vue_shared/components/source_viewer
parent2c29837ce1692790dedccbc9b36b44dc8aaacbee (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/vue_shared/components/source_viewer')
-rw-r--r--spec/frontend/vue_shared/components/source_viewer/components/chunk_spec.js18
1 files changed, 13 insertions, 5 deletions
diff --git a/spec/frontend/vue_shared/components/source_viewer/components/chunk_spec.js b/spec/frontend/vue_shared/components/source_viewer/components/chunk_spec.js
index d720574ce6d..657bd59dac6 100644
--- a/spec/frontend/vue_shared/components/source_viewer/components/chunk_spec.js
+++ b/spec/frontend/vue_shared/components/source_viewer/components/chunk_spec.js
@@ -1,10 +1,16 @@
+import { nextTick } from 'vue';
import { GlIntersectionObserver } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import Chunk from '~/vue_shared/components/source_viewer/components/chunk.vue';
import ChunkLine from '~/vue_shared/components/source_viewer/components/chunk_line.vue';
-import { scrollToElement } from '~/lib/utils/common_utils';
+import LineHighlighter from '~/blob/line_highlighter';
-jest.mock('~/lib/utils/common_utils');
+const lineHighlighter = new LineHighlighter();
+jest.mock('~/blob/line_highlighter', () =>
+ jest.fn().mockReturnValue({
+ highlightHash: jest.fn(),
+ }),
+);
const DEFAULT_PROPS = {
chunkIndex: 2,
@@ -104,12 +110,14 @@ describe('Chunk component', () => {
});
it('does not scroll to route hash if last chunk is not loaded', () => {
- expect(scrollToElement).not.toHaveBeenCalled();
+ expect(LineHighlighter).not.toHaveBeenCalled();
});
- it('scrolls to route hash if last chunk is loaded', () => {
+ it('scrolls to route hash if last chunk is loaded', async () => {
createComponent({ totalChunks: DEFAULT_PROPS.chunkIndex + 1 });
- expect(scrollToElement).toHaveBeenCalledWith(hash, { behavior: 'auto' });
+ await nextTick();
+ expect(LineHighlighter).toHaveBeenCalledWith({ scrollBehavior: 'auto' });
+ expect(lineHighlighter.highlightHash).toHaveBeenCalledWith(hash);
});
});
});