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-09-30 23:02:18 +05:30
import Editor from '~/editor/source_editor';
2020-04-08 14:13:33 +05:30
2021-09-30 23:02:18 +05:30
jest.mock('~/editor/source_editor');
2020-04-08 14:13:33 +05:30
describe('Blob utilities', () => {
2021-09-30 23:02:18 +05:30
describe('initSourceEditor', () => {
2020-04-08 14:13:33 +05:30
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', () => {
2021-09-30 23:02:18 +05:30
it('initializes the Source Editor', () => {
utils.initSourceEditor({ 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();
2021-09-30 23:02:18 +05:30
utils.initSourceEditor(params);
2020-10-24 23:57:45 +05:30
expect(Editor.prototype.createInstance).toHaveBeenCalledWith(params);
},
);
2020-04-08 14:13:33 +05:30
});
});
});