Skip to content

Commit

Permalink
[ADF-5372] - fixed wrong result pipe (#6925)
Browse files Browse the repository at this point in the history
* [ADF-5372] - fixed wrong result pipe

* [ADF-5372] - fixed missing radix on parseInt
  • Loading branch information
VitoAlbano committed Apr 15, 2021
1 parent 5a36367 commit 257614b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/core/pipes/file-size.pipe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ describe('FileSizePipe', () => {
it('returns empty string with invalid input', () => {
expect(pipe.transform(null)).toBe('');
expect(pipe.transform(undefined)).toBe('');
expect(pipe.transform(NaN)).toBe('');
});

it('should convert value to Bytes', () => {
Expand Down
9 changes: 7 additions & 2 deletions lib/core/pipes/file-size.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ export class FileSizePipe implements PipeTransform {
constructor(private translation: TranslationService) {
}

transform(bytes: number, decimals: number = 2): string {
if (bytes == null) {
transform(paramByte: any, decimals: number = 2): string {
if (paramByte == null) {
return '';
}

const bytes = parseInt(paramByte, 10);
if (isNaN(bytes)) {
return '';
}

Expand Down

0 comments on commit 257614b

Please sign in to comment.