diff options
author | Simon Knox <psimyn@gmail.com> | 2017-07-17 02:35:00 +0300 |
---|---|---|
committer | Simon Knox <psimyn@gmail.com> | 2017-08-08 15:12:08 +0300 |
commit | f36347980831347b2bf434f17918acfaf475dcf9 (patch) | |
tree | d43941f5c67eb6672582dd1330a3d56aca605f81 /spec | |
parent | 001dd56e7bfd04d22f5437569ba8aa60a0317a3e (diff) |
disable file upload button while uploading
hide placeholder text when files have been added
vertically center dropzone area content
close modal after file upload succeeds
Diffstat (limited to 'spec')
-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); + }); + }); +}); |