diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-31 21:09:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-31 21:09:10 +0300 |
commit | 62ddd3a00522d62ab23c7804e24dbe1c941bc0a7 (patch) | |
tree | 71f2cf18cdc83a3fce5221d05df3a792a562dd4e /spec/javascripts/dropzone_input_spec.js | |
parent | 1e6a9268646e7346519610492fc2a02d6655a663 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/javascripts/dropzone_input_spec.js')
-rw-r--r-- | spec/javascripts/dropzone_input_spec.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/javascripts/dropzone_input_spec.js b/spec/javascripts/dropzone_input_spec.js index 8d0f0d20d89..44a11097815 100644 --- a/spec/javascripts/dropzone_input_spec.js +++ b/spec/javascripts/dropzone_input_spec.js @@ -1,6 +1,7 @@ import $ from 'jquery'; import { TEST_HOST } from 'spec/test_constants'; import dropzoneInput from '~/dropzone_input'; +import PasteMarkdownTable from '~/behaviors/markdown/paste_markdown_table'; const TEST_FILE = new File([], 'somefile.jpg'); TEST_FILE.upload = {}; @@ -25,6 +26,34 @@ describe('dropzone_input', () => { expect(dropzone.version).toBeTruthy(); }); + describe('handlePaste', () => { + beforeEach(() => { + loadFixtures('issues/new-issue.html'); + + const form = $('#new_issue'); + form.data('uploads-path', TEST_UPLOAD_PATH); + dropzoneInput(form); + }); + + it('pastes Markdown tables', () => { + const event = $.Event('paste'); + const origEvent = new Event('paste'); + const pasteData = new DataTransfer(); + pasteData.setData('text/plain', 'hello world'); + pasteData.setData('text/html', '<table></table>'); + origEvent.clipboardData = pasteData; + event.originalEvent = origEvent; + + spyOn(PasteMarkdownTable, 'isTable').and.callThrough(); + spyOn(PasteMarkdownTable.prototype, 'convertToTableMarkdown').and.callThrough(); + + $('.js-gfm-input').trigger(event); + + expect(PasteMarkdownTable.isTable).toHaveBeenCalled(); + expect(PasteMarkdownTable.prototype.convertToTableMarkdown).toHaveBeenCalled(); + }); + }); + describe('shows error message', () => { let form; let dropzone; |