diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-08-08 17:45:49 +0300 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-08-08 17:45:49 +0300 |
commit | 6a6a1e5b9e0a82735f786ffedeacc7cbc33ed7cd (patch) | |
tree | a7fa95cb4ec7bceac8cf7a7fe42bc31e7c70ff77 /spec/javascripts | |
parent | b612a47da0e0225332a59ab961206f84602ad629 (diff) | |
parent | f36347980831347b2bf434f17918acfaf475dcf9 (diff) |
Merge branch '35052-please-select-a-file-when-attempting-to-upload-or-replace-from-the-ui' into 'master'
Resolve "'Please select a file' when attempting to upload or replace from the UI"
Closes #35052
See merge request !12863
Diffstat (limited to 'spec/javascripts')
-rw-r--r-- | spec/javascripts/blob/blob_file_dropzone_spec.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/javascripts/blob/blob_file_dropzone_spec.js b/spec/javascripts/blob/blob_file_dropzone_spec.js new file mode 100644 index 00000000000..2c8183ff77b --- /dev/null +++ b/spec/javascripts/blob/blob_file_dropzone_spec.js @@ -0,0 +1,42 @@ +import 'dropzone'; +import BlobFileDropzone from '~/blob/blob_file_dropzone'; + +describe('BlobFileDropzone', () => { + preloadFixtures('blob/show.html.raw'); + + beforeEach(() => { + loadFixtures('blob/show.html.raw'); + const form = $('.js-upload-blob-form'); + this.blobFileDropzone = new BlobFileDropzone(form, 'POST'); + this.dropzone = $('.js-upload-blob-form .dropzone').get(0).dropzone; + this.replaceFileButton = $('#submit-all'); + }); + + describe('submit button', () => { + it('requires file', () => { + spyOn(window, 'alert'); + + this.replaceFileButton.click(); + + expect(window.alert).toHaveBeenCalled(); + }); + + it('is disabled while uploading', () => { + spyOn(window, 'alert'); + + const file = { + name: 'some-file.jpg', + type: 'jpg', + }; + const fakeEvent = jQuery.Event('drop', { + dataTransfer: { files: [file] }, + }); + + this.dropzone.listeners[0].events.drop(fakeEvent); + this.replaceFileButton.click(); + + expect(window.alert).not.toHaveBeenCalled(); + expect(this.replaceFileButton.is(':disabled')).toEqual(true); + }); + }); +}); |