2018-03-09 20:18:59 +00:00
|
|
|
import $ from 'jquery';
|
2017-07-16 23:35:00 +00:00
|
|
|
import BlobFileDropzone from '~/blob/blob_file_dropzone';
|
|
|
|
|
2018-10-17 07:13:26 +00:00
|
|
|
describe('BlobFileDropzone', function() {
|
2019-03-26 16:03:28 +00:00
|
|
|
preloadFixtures('blob/show.html');
|
2017-07-16 23:35:00 +00:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2019-03-26 16:03:28 +00:00
|
|
|
loadFixtures('blob/show.html');
|
2017-07-16 23:35:00 +00:00
|
|
|
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');
|
|
|
|
|
2019-09-10 09:10:51 +00:00
|
|
|
const file = new File([], 'some-file.jpg');
|
2018-03-09 20:18:59 +00:00
|
|
|
const fakeEvent = $.Event('drop', {
|
2017-07-16 23:35:00 +00:00
|
|
|
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);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|