debian-mirror-gitlab/spec/javascripts/blob/blob_file_dropzone_spec.js

43 lines
1.1 KiB
JavaScript
Raw Normal View History

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() {
2017-09-10 17:25:29 +05:30
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',
};
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);
});
});
});