diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/frontend/repository/components/blob_content_viewer_spec.js | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/frontend/repository/components/blob_content_viewer_spec.js')
-rw-r--r-- | spec/frontend/repository/components/blob_content_viewer_spec.js | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/spec/frontend/repository/components/blob_content_viewer_spec.js b/spec/frontend/repository/components/blob_content_viewer_spec.js index 96c03419dd6..2f6de03b73d 100644 --- a/spec/frontend/repository/components/blob_content_viewer_spec.js +++ b/spec/frontend/repository/components/blob_content_viewer_spec.js @@ -25,6 +25,7 @@ import { redirectTo } from '~/lib/utils/url_utility'; import { isLoggedIn } 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'; import { simpleViewerMock, richViewerMock, @@ -39,6 +40,7 @@ import { jest.mock('~/repository/components/blob_viewers'); jest.mock('~/lib/utils/url_utility'); jest.mock('~/lib/utils/common_utils'); +jest.mock('~/blob/line_highlighter'); let wrapper; let mockResolver; @@ -173,20 +175,30 @@ describe('Blob content viewer component', () => { }); describe('legacy viewers', () => { + const legacyViewerUrl = 'some_file.js?format=json&viewer=simple'; + const fileType = 'text'; + const highlightJs = false; + it('loads a legacy viewer when a the fileType is text and the highlightJs feature is turned off', async () => { await createComponent({ - blob: { ...simpleViewerMock, fileType: 'text', highlightJs: false }, + blob: { ...simpleViewerMock, fileType, highlightJs }, }); expect(mockAxios.history.get).toHaveLength(1); - expect(mockAxios.history.get[0].url).toEqual('some_file.js?format=json&viewer=simple'); + expect(mockAxios.history.get[0].url).toBe(legacyViewerUrl); }); it('loads a legacy viewer when a viewer component is not available', async () => { await createComponent({ blob: { ...simpleViewerMock, fileType: 'unknown' } }); expect(mockAxios.history.get).toHaveLength(1); - expect(mockAxios.history.get[0].url).toEqual('some_file.js?format=json&viewer=simple'); + expect(mockAxios.history.get[0].url).toBe(legacyViewerUrl); + }); + + it('loads the LineHighlighter', async () => { + mockAxios.onGet(legacyViewerUrl).replyOnce(httpStatusCodes.OK, 'test'); + await createComponent({ blob: { ...simpleViewerMock, fileType, highlightJs } }); + expect(LineHighlighter).toHaveBeenCalled(); }); }); }); @@ -258,6 +270,7 @@ describe('Blob content viewer component', () => { codeNavigationPath: simpleViewerMock.codeNavigationPath, blobPath: simpleViewerMock.path, pathPrefix: simpleViewerMock.projectBlobPathRoot, + wrapTextNodes: true, }); }); |