summaryrefslogtreecommitdiff
path: root/spec/frontend/pipeline_editor/components/text_editor_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/pipeline_editor/components/text_editor_spec.js')
-rw-r--r--spec/frontend/pipeline_editor/components/text_editor_spec.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/frontend/pipeline_editor/components/text_editor_spec.js b/spec/frontend/pipeline_editor/components/text_editor_spec.js
new file mode 100644
index 00000000000..39d205839f4
--- /dev/null
+++ b/spec/frontend/pipeline_editor/components/text_editor_spec.js
@@ -0,0 +1,41 @@
+import { shallowMount } from '@vue/test-utils';
+import EditorLite from '~/vue_shared/components/editor_lite.vue';
+import { mockCiYml } from '../mock_data';
+
+import TextEditor from '~/pipeline_editor/components/text_editor.vue';
+
+describe('~/pipeline_editor/components/text_editor.vue', () => {
+ let wrapper;
+
+ const createComponent = (props = {}, mountFn = shallowMount) => {
+ wrapper = mountFn(TextEditor, {
+ propsData: {
+ value: mockCiYml,
+ ...props,
+ },
+ });
+ };
+
+ const findEditor = () => wrapper.find(EditorLite);
+
+ it('contains an editor', () => {
+ createComponent();
+
+ expect(findEditor().exists()).toBe(true);
+ });
+
+ it('editor contains the value provided', () => {
+ expect(findEditor().props('value')).toBe(mockCiYml);
+ });
+
+ it('editor is readony and configured for .yml', () => {
+ expect(findEditor().props('editorOptions')).toEqual({ readOnly: true });
+ expect(findEditor().props('fileName')).toBe('*.yml');
+ });
+
+ it('bubbles up editor-ready event', () => {
+ findEditor().vm.$emit('editor-ready');
+
+ expect(wrapper.emitted('editor-ready')).toHaveLength(1);
+ });
+});