debian-mirror-gitlab/spec/frontend/blob/utils_spec.js

45 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-04-08 14:13:33 +05:30
import * as utils from '~/blob/utils';
2021-03-11 19:13:27 +05:30
import Editor from '~/editor/editor_lite';
2020-04-08 14:13:33 +05:30
2020-10-24 23:57:45 +05:30
jest.mock('~/editor/editor_lite');
2020-04-08 14:13:33 +05:30
describe('Blob utilities', () => {
describe('initEditorLite', () => {
let editorEl;
const blobPath = 'foo.txt';
const blobContent = 'Foo bar';
2020-10-24 23:57:45 +05:30
const blobGlobalId = 'snippet_777';
2020-04-08 14:13:33 +05:30
beforeEach(() => {
2020-10-24 23:57:45 +05:30
editorEl = document.createElement('div');
2020-04-08 14:13:33 +05:30
});
describe('Monaco editor', () => {
it('initializes the Editor Lite', () => {
utils.initEditorLite({ el: editorEl });
2020-10-24 23:57:45 +05:30
expect(Editor).toHaveBeenCalledWith({
scrollbar: {
alwaysConsumeMouseWheel: false,
},
});
2020-04-08 14:13:33 +05:30
});
2020-10-24 23:57:45 +05:30
it.each([[{}], [{ blobPath, blobContent, blobGlobalId }]])(
'creates the instance with the passed parameters %s',
2021-03-08 18:12:59 +05:30
(extraParams) => {
2020-10-24 23:57:45 +05:30
const params = {
2020-04-08 14:13:33 +05:30
el: editorEl,
2020-10-24 23:57:45 +05:30
...extraParams,
};
2020-04-08 14:13:33 +05:30
2020-10-24 23:57:45 +05:30
expect(Editor.prototype.createInstance).not.toHaveBeenCalled();
utils.initEditorLite(params);
expect(Editor.prototype.createInstance).toHaveBeenCalledWith(params);
},
);
2020-04-08 14:13:33 +05:30
});
});
});