import $ from 'jquery'; import mock from 'xhr-mock'; import { TEST_HOST } from 'spec/test_constants'; import dropzoneInput from '~/dropzone_input'; import PasteMarkdownTable from '~/behaviors/markdown/paste_markdown_table'; import waitForPromises from 'helpers/wait_for_promises'; const TEST_FILE = new File([], 'somefile.jpg'); TEST_FILE.upload = {}; const TEST_UPLOAD_PATH = `${TEST_HOST}/upload/file`; const TEST_ERROR_MESSAGE = 'A big error occurred!'; const TEMPLATE = `
`; describe('dropzone_input', () => { it('returns null when failed to initialize', () => { const dropzone = dropzoneInput($('')); expect(dropzone).toBeNull(); }); it('returns valid dropzone when successfully initialize', () => { const dropzone = dropzoneInput($(TEMPLATE)); 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'); origEvent.clipboardData = { types: ['text/plain', 'text/html'], getData: () => 'Hello World |