diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 18:42:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 18:42:06 +0000 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /spec/frontend/blob/utils_spec.js | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) | |
download | gitlab-ce-6e4e1050d9dba2b7b2523fdd1768823ab85feef4.tar.gz |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/frontend/blob/utils_spec.js')
-rw-r--r-- | spec/frontend/blob/utils_spec.js | 51 |
1 files changed, 21 insertions, 30 deletions
diff --git a/spec/frontend/blob/utils_spec.js b/spec/frontend/blob/utils_spec.js index 119ed2dfe7a..ab9e325e963 100644 --- a/spec/frontend/blob/utils_spec.js +++ b/spec/frontend/blob/utils_spec.js @@ -1,53 +1,44 @@ import Editor from '~/editor/editor_lite'; import * as utils from '~/blob/utils'; -const mockCreateMonacoInstance = jest.fn(); -jest.mock('~/editor/editor_lite', () => { - return jest.fn().mockImplementation(() => { - return { createInstance: mockCreateMonacoInstance }; - }); -}); +jest.mock('~/editor/editor_lite'); describe('Blob utilities', () => { - beforeEach(() => { - Editor.mockClear(); - }); - describe('initEditorLite', () => { let editorEl; const blobPath = 'foo.txt'; const blobContent = 'Foo bar'; + const blobGlobalId = 'snippet_777'; beforeEach(() => { - setFixtures('<div id="editor"></div>'); - editorEl = document.getElementById('editor'); + editorEl = document.createElement('div'); }); describe('Monaco editor', () => { it('initializes the Editor Lite', () => { utils.initEditorLite({ el: editorEl }); - expect(Editor).toHaveBeenCalled(); + expect(Editor).toHaveBeenCalledWith({ + scrollbar: { + alwaysConsumeMouseWheel: false, + }, + }); }); - it('creates the instance with the passed parameters', () => { - utils.initEditorLite({ el: editorEl }); - expect(mockCreateMonacoInstance.mock.calls[0]).toEqual([ - { + it.each([[{}], [{ blobPath, blobContent, blobGlobalId }]])( + 'creates the instance with the passed parameters %s', + extraParams => { + const params = { el: editorEl, - blobPath: undefined, - blobContent: undefined, - }, - ]); + ...extraParams, + }; - utils.initEditorLite({ el: editorEl, blobPath, blobContent }); - expect(mockCreateMonacoInstance.mock.calls[1]).toEqual([ - { - el: editorEl, - blobPath, - blobContent, - }, - ]); - }); + expect(Editor.prototype.createInstance).not.toHaveBeenCalled(); + + utils.initEditorLite(params); + + expect(Editor.prototype.createInstance).toHaveBeenCalledWith(params); + }, + ); }); }); }); |