use of org.uberfire.client.views.pfly.monaco.jsinterop.MonacoEditor in project kie-wb-common by kiegroup.
the class MonacoEditorDOMElementTest method testSetupInternalComponent.
@Test
public void testSetupInternalComponent() {
final Element element = mock(Element.class);
final Style style = mock(Style.class);
final elemental2.dom.Element mockedElement = mock(elemental2.dom.Element.class);
final MonacoPropertiesFactory properties = mock(MonacoPropertiesFactory.class);
final JavaScriptObject constructionOptions = mock(JavaScriptObject.class);
final MonacoEditor editor = mock(MonacoEditor.class);
final MonacoStandaloneCodeEditor standaloneCodeEditor = mock(MonacoStandaloneCodeEditor.class);
final com.google.gwt.user.client.Element gwtElement = mock(com.google.gwt.user.client.Element.class);
final MonacoStandaloneCodeEditor.CallbackFunction onKeyDown = mock(MonacoStandaloneCodeEditor.CallbackFunction.class);
final MonacoStandaloneCodeEditor.CallbackFunction widgetTrigger = mock(MonacoStandaloneCodeEditor.CallbackFunction.class);
final NativeEvent blurEvent = mock(NativeEvent.class);
when(widget.getElement()).thenReturn(element);
when(element.getStyle()).thenReturn(style);
when(domElement.uncheckedCast(any())).thenReturn(mockedElement);
when(properties.getConstructionOptions()).thenReturn(constructionOptions);
doReturn(onKeyDown).when(domElement).getOnKeyDown(standaloneCodeEditor);
doReturn(widgetTrigger).when(domElement).getWidgetTrigger(blurEvent);
doReturn(blurEvent).when(domElement).getBlurEvent();
doReturn(properties).when(domElement).makeMonacoPropertiesFactory();
doReturn(editor).when(domElement).getMonacoEditor();
doReturn(standaloneCodeEditor).when(editor).create(mockedElement, constructionOptions);
domElement.setupInternalComponent();
verify(style).setWidth(100, PCT);
verify(style).setHeight(100, PCT);
verify(standaloneCodeEditor).onKeyDown(onKeyDown);
verify(standaloneCodeEditor).onDidBlurEditorWidget(widgetTrigger);
verify(widget).setCodeEditor(standaloneCodeEditor);
verify(widget).setFocus(true);
}
Aggregations