diff options
author | Clement Ho <clemmakesapps@gmail.com> | 2017-06-28 01:42:12 +0300 |
---|---|---|
committer | Clement Ho <clemmakesapps@gmail.com> | 2017-06-28 01:42:12 +0300 |
commit | f8c503b8b0156ad81c0a1d44b8d338963f6afdb1 (patch) | |
tree | a787e783f982db882206076f9971cbf8dc79329c /spec | |
parent | d61836103d32d51557a94658988f3a7a0b6930de (diff) |
Revert "Merge branch 'issue-form-multiple-line-markdown' into 'master'"
This reverts merge request !12458
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/vue_shared/components/markdown/field_spec.js | 105 |
1 files changed, 36 insertions, 69 deletions
diff --git a/spec/javascripts/vue_shared/components/markdown/field_spec.js b/spec/javascripts/vue_shared/components/markdown/field_spec.js index 291e19c9f3c..4bbaff561fc 100644 --- a/spec/javascripts/vue_shared/components/markdown/field_spec.js +++ b/spec/javascripts/vue_shared/components/markdown/field_spec.js @@ -4,33 +4,47 @@ import fieldComponent from '~/vue_shared/components/markdown/field.vue'; describe('Markdown field component', () => { let vm; - beforeEach((done) => { + beforeEach(() => { vm = new Vue({ - data() { - return { - text: 'testing\n123', - }; - }, - components: { - fieldComponent, + render(createElement) { + return createElement( + fieldComponent, + { + props: { + markdownPreviewUrl: '/preview', + markdownDocs: '/docs', + }, + }, + [ + createElement('textarea', { + slot: 'textarea', + }), + ], + ); }, - template: ` - <field-component - marodown-preview-url="/preview" - markdown-docs="/docs" - > - <textarea - slot="textarea" - v-model="text"> - </textarea> - </field-component> - `, - }).$mount(); - - Vue.nextTick(done); + }); + }); + + it('creates a new instance of GL form', (done) => { + spyOn(gl, 'GLForm'); + vm.$mount(); + + Vue.nextTick(() => { + expect( + gl.GLForm, + ).toHaveBeenCalled(); + + done(); + }); }); describe('mounted', () => { + beforeEach((done) => { + vm.$mount(); + + Vue.nextTick(done); + }); + it('renders textarea inside backdrop', () => { expect( vm.$el.querySelector('.zen-backdrop textarea'), @@ -103,52 +117,5 @@ describe('Markdown field component', () => { }); }); }); - - describe('markdown buttons', () => { - it('converts single words', (done) => { - const textarea = vm.$el.querySelector('textarea'); - - textarea.setSelectionRange(0, 7); - vm.$el.querySelector('.js-md').click(); - - Vue.nextTick(() => { - expect( - textarea.value, - ).toContain('**testing**'); - - done(); - }); - }); - - it('converts a line', (done) => { - const textarea = vm.$el.querySelector('textarea'); - - textarea.setSelectionRange(0, 0); - vm.$el.querySelectorAll('.js-md')[4].click(); - - Vue.nextTick(() => { - expect( - textarea.value, - ).toContain('* testing'); - - done(); - }); - }); - - it('converts multiple lines', (done) => { - const textarea = vm.$el.querySelector('textarea'); - - textarea.setSelectionRange(0, 50); - vm.$el.querySelectorAll('.js-md')[4].click(); - - Vue.nextTick(() => { - expect( - textarea.value, - ).toContain('* testing\n* 123'); - - done(); - }); - }); - }); }); }); |