diff options
Diffstat (limited to 'spec/frontend/pipeline_wizard/components/editor_spec.js')
-rw-r--r-- | spec/frontend/pipeline_wizard/components/editor_spec.js | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/spec/frontend/pipeline_wizard/components/editor_spec.js b/spec/frontend/pipeline_wizard/components/editor_spec.js index 26e4b8eb0ea..dd0a609043a 100644 --- a/spec/frontend/pipeline_wizard/components/editor_spec.js +++ b/spec/frontend/pipeline_wizard/components/editor_spec.js @@ -3,12 +3,20 @@ import { Document } from 'yaml'; import YamlEditor from '~/pipeline_wizard/components/editor.vue'; describe('Pages Yaml Editor wrapper', () => { + let wrapper; + const defaultOptions = { propsData: { doc: new Document({ foo: 'bar' }), filename: 'foo.yml' }, }; + afterEach(() => { + wrapper.destroy(); + }); + describe('mount hook', () => { - const wrapper = mount(YamlEditor, defaultOptions); + beforeEach(() => { + wrapper = mount(YamlEditor, defaultOptions); + }); it('editor is mounted', () => { expect(wrapper.vm.editor).not.toBeUndefined(); @@ -19,16 +27,11 @@ describe('Pages Yaml Editor wrapper', () => { describe('watchers', () => { describe('doc', () => { const doc = new Document({ baz: ['bar'] }); - let wrapper; beforeEach(() => { wrapper = mount(YamlEditor, defaultOptions); }); - afterEach(() => { - wrapper.destroy(); - }); - it("causes the editor's value to be set to the stringified document", async () => { await wrapper.setProps({ doc }); expect(wrapper.vm.editor.getValue()).toEqual(doc.toString()); @@ -48,7 +51,10 @@ describe('Pages Yaml Editor wrapper', () => { describe('highlight', () => { const highlight = 'foo'; - const wrapper = mount(YamlEditor, defaultOptions); + + beforeEach(() => { + wrapper = mount(YamlEditor, defaultOptions); + }); it('calls editor.highlight(path, keep=true)', async () => { const highlightSpy = jest.spyOn(wrapper.vm.yamlEditorExtension.obj, 'highlight'); |