2020-03-09 05:07:45 -04:00
|
|
|
import * as utils from '~/blob/utils';
|
2021-06-18 17:10:06 -04:00
|
|
|
import Editor from '~/editor/source_editor';
|
2020-03-09 05:07:45 -04:00
|
|
|
|
2021-06-18 17:10:06 -04:00
|
|
|
jest.mock('~/editor/source_editor');
|
2020-03-09 05:07:45 -04:00
|
|
|
|
|
|
|
describe('Blob utilities', () => {
|
2021-06-18 17:10:06 -04:00
|
|
|
describe('initSourceEditor', () => {
|
2020-03-09 05:07:45 -04:00
|
|
|
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', () => {
|
2021-06-18 17:10:06 -04:00
|
|
|
it('initializes the Source Editor', () => {
|
|
|
|
utils.initSourceEditor({ 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',
|
2020-12-23 16:10:24 -05:00
|
|
|
(extraParams) => {
|
2020-08-11 23:10:17 -04:00
|
|
|
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();
|
|
|
|
|
2021-06-18 17:10:06 -04:00
|
|
|
utils.initSourceEditor(params);
|
2020-08-11 23:10:17 -04:00
|
|
|
|
|
|
|
expect(Editor.prototype.createInstance).toHaveBeenCalledWith(params);
|
|
|
|
},
|
|
|
|
);
|
2020-03-09 05:07:45 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|