Skip to content

Commit

Permalink
add uploader tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-kotov-dx committed Apr 14, 2022
1 parent 597fb6c commit ad83c91
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions test/unit/modules/uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,64 @@ describe('Uploader', function() {

expect(dropEvent.defaultPrevented).toBeTrue();
});

it('check preventImageUploading on', function() {
const testRange = new Range(0);
const file = {
name: 'test.png',
type: 'image/png',
};
let uploads = [];

const quillMock = {
root: {
addEventListener: () => {},
},
};

const uploaderInstance = new Uploader(quillMock, {
mimetypes: Uploader.DEFAULTS.mimetypes,
handler: (range, files) => {
uploads = files;
},
});

uploaderInstance.preventImageUploading(true);

uploaderInstance.upload(testRange, [file]);

expect(uploaderInstance.preventImageUploading()).toBeTrue();
expect(uploads.length).toEqual(0);
});

it('check preventImageUploading off', function() {
const testRange = new Range(0);
const file = {
name: 'test.png',
type: 'image/png',
};
let uploads = [];

const quillMock = {
root: {
addEventListener: () => {},
},
};

const uploaderInstance = new Uploader(quillMock, {
mimetypes: Uploader.DEFAULTS.mimetypes,
handler: (range, files) => {
uploads = files;
},
});

uploaderInstance.preventImageUploading(true);
uploaderInstance.preventImageUploading(false);

uploaderInstance.upload(testRange, [file]);

expect(uploaderInstance.preventImageUploading()).toBeFalse();
expect(uploads.length).toEqual(1);
});
});
});

0 comments on commit ad83c91

Please sign in to comment.