Commit 6be7d6be authored by Denys Mishunov's avatar Denys Mishunov

Correctly pass instance in EDITOR_READY_EVENT

Changelog: fixed
parent cce3194c
......@@ -149,7 +149,7 @@ export default class SourceEditor {
});
this.instances.push(instance);
el.dispatchEvent(new CustomEvent(EDITOR_READY_EVENT, { instance }));
el.dispatchEvent(new CustomEvent(EDITOR_READY_EVENT, { detail: { instance } }));
return instance;
}
......
......@@ -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);
});
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment