Search in sources :

Example 6 with MonacoStandaloneCodeEditor

use of org.uberfire.client.views.pfly.monaco.jsinterop.MonacoStandaloneCodeEditor in project kie-wb-common by kiegroup.

the class MonacoEditorDOMElementTest method testGetOnKeyDownWhenSuggestWidgetIsNotVisibleAndKeyCodeIsEsc.

@Test
public void testGetOnKeyDownWhenSuggestWidgetIsNotVisibleAndKeyCodeIsEsc() {
    final MonacoStandaloneCodeEditor codeEditor = mock(MonacoStandaloneCodeEditor.class);
    final NativeEvent event = mock(NativeEvent.class);
    when(event.getKeyCode()).thenReturn(9);
    when(codeEditor.isSuggestWidgetVisible()).thenReturn(false);
    domElement.getOnKeyDown(codeEditor).call(event);
    verify(codeEditor, never()).trigger("keyboard", "cursorHome");
    verify(codeEditor, never()).trigger("keyboard", "cursorEnd");
    verify(event, never()).stopPropagation();
    verify(event, never()).preventDefault();
}
Also used : MonacoStandaloneCodeEditor(org.uberfire.client.views.pfly.monaco.jsinterop.MonacoStandaloneCodeEditor) NativeEvent(com.google.gwt.dom.client.NativeEvent) Test(org.junit.Test)

Example 7 with MonacoStandaloneCodeEditor

use of org.uberfire.client.views.pfly.monaco.jsinterop.MonacoStandaloneCodeEditor in project kie-wb-common by kiegroup.

the class MonacoEditorViewTest method testLoadStandaloneEditor.

@Test
public void testLoadStandaloneEditor() {
    MonacoStandaloneCodeEditor editor = mock(MonacoStandaloneCodeEditor.class);
    tested.load(editor, 300, 100);
    ArgumentCaptor<MonacoStandaloneCodeEditor.CallbackFunction> captor = ArgumentCaptor.forClass(MonacoStandaloneCodeEditor.CallbackFunction.class);
    verify(editor, times(1)).onDidBlurEditorWidget(captor.capture());
    verify(editor, times(1)).layout(any());
    captor.getValue().call(mock(NativeEvent.class));
    verify(presenter, times(1)).onValueChanged();
}
Also used : MonacoStandaloneCodeEditor(org.uberfire.client.views.pfly.monaco.jsinterop.MonacoStandaloneCodeEditor) NativeEvent(com.google.gwt.dom.client.NativeEvent) Test(org.junit.Test)

Aggregations

MonacoStandaloneCodeEditor (org.uberfire.client.views.pfly.monaco.jsinterop.MonacoStandaloneCodeEditor)7 NativeEvent (com.google.gwt.dom.client.NativeEvent)6 Test (org.junit.Test)6 Style (com.google.gwt.dom.client.Style)2 MonacoPropertiesFactory (org.kie.workbench.common.dmn.client.widgets.codecompletion.MonacoPropertiesFactory)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 Element (com.google.gwt.user.client.Element)1 MonacoEditor (org.uberfire.client.views.pfly.monaco.jsinterop.MonacoEditor)1