[ADF-5372] - fixed wrong result pipe (#6925)

* [ADF-5372] - fixed wrong result pipe

* [ADF-5372] - fixed missing radix on parseInt
This commit is contained in:
Vito
2021-04-15 09:55:51 +01:00
committed by GitHub
parent 5a363670a0
commit 257614bfc0
2 changed files with 8 additions and 2 deletions

View File

@@ -44,6 +44,7 @@ describe('FileSizePipe', () => {
it('returns empty string with invalid input', () => { it('returns empty string with invalid input', () => {
expect(pipe.transform(null)).toBe(''); expect(pipe.transform(null)).toBe('');
expect(pipe.transform(undefined)).toBe(''); expect(pipe.transform(undefined)).toBe('');
expect(pipe.transform(NaN)).toBe('');
}); });
it('should convert value to Bytes', () => { it('should convert value to Bytes', () => {

View File

@@ -27,8 +27,13 @@ export class FileSizePipe implements PipeTransform {
constructor(private translation: TranslationService) { constructor(private translation: TranslationService) {
} }
transform(bytes: number, decimals: number = 2): string { transform(paramByte: any, decimals: number = 2): string {
if (bytes == null) { if (paramByte == null) {
return '';
}
const bytes = parseInt(paramByte, 10);
if (isNaN(bytes)) {
return ''; return '';
} }