blob: ab9e325e9634c1547a91213a7186348df4a1c80e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
import Editor from '~/editor/editor_lite';
import * as utils from '~/blob/utils';
jest.mock('~/editor/editor_lite');
describe('Blob utilities', () => {
describe('initEditorLite', () => {
let editorEl;
const blobPath = 'foo.txt';
const blobContent = 'Foo bar';
const blobGlobalId = 'snippet_777';
beforeEach(() => {
editorEl = document.createElement('div');
});
describe('Monaco editor', () => {
it('initializes the Editor Lite', () => {
utils.initEditorLite({ el: editorEl });
expect(Editor).toHaveBeenCalledWith({
scrollbar: {
alwaysConsumeMouseWheel: false,
},
});
});
it.each([[{}], [{ blobPath, blobContent, blobGlobalId }]])(
'creates the instance with the passed parameters %s',
extraParams => {
const params = {
el: editorEl,
...extraParams,
};
expect(Editor.prototype.createInstance).not.toHaveBeenCalled();
utils.initEditorLite(params);
expect(Editor.prototype.createInstance).toHaveBeenCalledWith(params);
},
);
});
});
});
|