Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eamahanna committed Oct 23, 2020
1 parent 4afdc29 commit e3e0076
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions test/unit/spec/narrative_core/upload/fileUploadWidget-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ define([
});
});

it('Should create a clear all button when a file upload error occurs', (done) => {
it('Should render properly when a file upload error occurs', (done) => {
// Set the file max size to 0
fuWidget.dropzone.options.maxFilesize = 1;

Expand All @@ -164,30 +164,7 @@ define([
fuWidget.dropzone.addFile(mockFile);
setTimeout(() => {
expect(adderMock).toHaveBeenCalled();
var clearAllButton = document.getElementById('clear-all-btn');
expect(clearAllButton).toBeDefined();
done();
});
});

it('Should display an error icon and hide the progress bar and cancel button when an error occurs', (done) => {
fuWidget.dropzone.options.maxFilesize = 1;

// Create file
const filename='foo.txt';
mockUploadEndpoint(filename, fakeUser, false);
var mockFile = createMockFile(filename);
Object.defineProperty(mockFile, 'size', {value: Math.pow(1024, 4), writable: false});

// Create mock calls
const adderMock = jasmine.createSpy('adderMock');
fuWidget.dropzone.on('addedfile', () => {
adderMock();
});

fuWidget.dropzone.addFile(mockFile);
setTimeout(() => {
expect(adderMock).toHaveBeenCalled();
expect(document.getElementById('clear-all-btn')).toBeDefined();
expect(document.getElementById('upload_progress_and_cancel')).toBeNull();
expect(document.getElementById('error_icon')).toBeDefined();
done();
Expand Down

0 comments on commit e3e0076

Please sign in to comment.