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