summaryrefslogtreecommitdiff
path: root/spec/frontend/repository/components/blob_content_viewer_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/repository/components/blob_content_viewer_spec.js')
-rw-r--r--spec/frontend/repository/components/blob_content_viewer_spec.js16
1 files changed, 15 insertions, 1 deletions
diff --git a/spec/frontend/repository/components/blob_content_viewer_spec.js b/spec/frontend/repository/components/blob_content_viewer_spec.js
index 2ab4afbffbe..d498b6f0c4f 100644
--- a/spec/frontend/repository/components/blob_content_viewer_spec.js
+++ b/spec/frontend/repository/components/blob_content_viewer_spec.js
@@ -22,7 +22,7 @@ import userInfoQuery from '~/repository/queries/user_info.query.graphql';
import applicationInfoQuery from '~/repository/queries/application_info.query.graphql';
import CodeIntelligence from '~/code_navigation/components/app.vue';
import { redirectTo } from '~/lib/utils/url_utility';
-import { isLoggedIn } from '~/lib/utils/common_utils';
+import { isLoggedIn, handleLocationHash } from '~/lib/utils/common_utils';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import httpStatusCodes from '~/lib/utils/http_status';
import LineHighlighter from '~/blob/line_highlighter';
@@ -163,6 +163,14 @@ describe('Blob content viewer component', () => {
expect(findBlobHeader().props('blob')).toEqual(simpleViewerMock);
});
+ it('copies blob text to clipboard', async () => {
+ jest.spyOn(navigator.clipboard, 'writeText');
+ await createComponent();
+
+ findBlobHeader().vm.$emit('copy');
+ expect(navigator.clipboard.writeText).toHaveBeenCalledWith(simpleViewerMock.rawTextBlob);
+ });
+
it('renders a BlobContent component', async () => {
await createComponent();
@@ -209,6 +217,12 @@ describe('Blob content viewer component', () => {
await createComponent({ blob: { ...simpleViewerMock, fileType, highlightJs } });
expect(LineHighlighter).toHaveBeenCalled();
});
+
+ it('scrolls to the hash', async () => {
+ mockAxios.onGet(legacyViewerUrl).replyOnce(httpStatusCodes.OK, 'test');
+ await createComponent({ blob: { ...simpleViewerMock, fileType, highlightJs } });
+ expect(handleLocationHash).toHaveBeenCalled();
+ });
});
});