mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[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:
committed by
Popovics András
parent
75b0267f0b
commit
70ce85602d
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user