diff options
Diffstat (limited to 'spec/frontend/editor/source_editor_spec.js')
-rw-r--r-- | spec/frontend/editor/source_editor_spec.js | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/spec/frontend/editor/source_editor_spec.js b/spec/frontend/editor/source_editor_spec.js index bc53202c919..049cab3a83b 100644 --- a/spec/frontend/editor/source_editor_spec.js +++ b/spec/frontend/editor/source_editor_spec.js @@ -342,27 +342,30 @@ describe('Base editor', () => { describe('implementation', () => { let instance; - beforeEach(() => { - instance = editor.createInstance({ el: editorEl, blobPath, blobContent }); - }); it('correctly proxies value from the model', () => { + instance = editor.createInstance({ el: editorEl, blobPath, blobContent }); expect(instance.getValue()).toBe(blobContent); }); - it('emits the EDITOR_READY_EVENT event after setting up the instance', () => { + it('emits the EDITOR_READY_EVENT event passing the instance after setting it up', () => { jest.spyOn(monacoEditor, 'create').mockImplementation(() => { return { setModel: jest.fn(), onDidDispose: jest.fn(), layout: jest.fn(), + dispose: jest.fn(), }; }); - const eventSpy = jest.fn(); + let passedInstance; + const eventSpy = jest.fn().mockImplementation((ev) => { + passedInstance = ev.detail.instance; + }); editorEl.addEventListener(EDITOR_READY_EVENT, eventSpy); expect(eventSpy).not.toHaveBeenCalled(); - editor.createInstance({ el: editorEl }); + instance = editor.createInstance({ el: editorEl }); expect(eventSpy).toHaveBeenCalled(); + expect(passedInstance).toBe(instance); }); }); |