[ADF-788] fix error negative and zero value for max file size (#2590)

* fix error negative and zero value for max file size

* fix null scenario
This commit is contained in:
Eugenio Romano
2017-11-02 10:43:38 +00:00
committed by Popovics András
parent 75b0267f0b
commit 70ce85602d
2 changed files with 17 additions and 1 deletions
@@ -283,6 +283,22 @@ describe('UploadButtonComponent', () => {
expect(filesCalledWith[0].name).toBe('smallFile.png');
});
it('should filter out all files if maxFilesSize is 0', () => {
component.maxFilesSize = 0;
component.uploadFiles(files);
expect(addToQueueSpy.calls.mostRecent()).toBeUndefined();
});
it('should filter out all files if maxFilesSize is <0', () => {
component.maxFilesSize = -2;
component.uploadFiles(files);
expect(addToQueueSpy.calls.mostRecent()).toBeUndefined();
});
it('should output an error when you try to upload a file too big', (done) => {
component.maxFilesSize = 100;
@@ -225,7 +225,7 @@ export class UploadButtonComponent implements OnInit, OnChanges, NodePermissionS
private isFileSizeAcceptable(file: FileModel): boolean {
let acceptableSize = true;
if (this.maxFilesSize && file.size > this.maxFilesSize) {
if ((this.maxFilesSize !== undefined && this.maxFilesSize !== null ) && (this.maxFilesSize <= 0 || file.size > this.maxFilesSize)) {
acceptableSize = false;
this.translateService.get('FILE_UPLOAD.MESSAGES.EXCEED_MAX_FILE_SIZE', {fileName: file.name}).subscribe((message: string) => {