2018-05-09 12:01:36 +05:30
|
|
|
import $ from 'jquery';
|
2017-09-10 17:25:29 +05:30
|
|
|
import BlobFileDropzone from '~/blob/blob_file_dropzone';
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
describe('BlobFileDropzone', function() {
|
2019-05-18 00:54:41 +05:30
|
|
|
preloadFixtures('blob/show.html');
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
beforeEach(() => {
|
2019-05-18 00:54:41 +05:30
|
|
|
loadFixtures('blob/show.html');
|
2017-09-10 17:25:29 +05:30
|
|
|
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',
|
|
|
|
};
|
2018-05-09 12:01:36 +05:30
|
|
|
const fakeEvent = $.Event('drop', {
|
2017-09-10 17:25:29 +05:30
|
|
|
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);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|