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