diff options
Diffstat (limited to 'spec/support/helpers/features/source_editor_spec_helpers.rb')
-rw-r--r-- | spec/support/helpers/features/source_editor_spec_helpers.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/support/helpers/features/source_editor_spec_helpers.rb b/spec/support/helpers/features/source_editor_spec_helpers.rb new file mode 100644 index 00000000000..57057b47fbb --- /dev/null +++ b/spec/support/helpers/features/source_editor_spec_helpers.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +# These helpers help you interact within the Source Editor (single-file editor, snippets, etc.). +# +module Spec + module Support + module Helpers + module Features + module SourceEditorSpecHelpers + include ActionView::Helpers::JavaScriptHelper + + def editor_set_value(value) + editor = find('.monaco-editor') + uri = editor['data-uri'] + + execute_script("monaco.editor.getModel('#{uri}').setValue('#{escape_javascript(value)}')") + end + + def editor_get_value + editor = find('.monaco-editor') + uri = editor['data-uri'] + + evaluate_script("monaco.editor.getModel('#{uri}').getValue()") + end + end + end + end + end +end |