Merge "fix: Fix for getGBValue return"

This commit is contained in:
Zuul 2021-09-01 07:59:44 +00:00 committed by Gerrit Code Review
commit cd917640eb
2 changed files with 8 additions and 8 deletions

View File

@ -85,7 +85,7 @@ export const getYesNo = (input) => (input ? t('Yes') : t('No'));
export const getGBValue = (input) => {
const gb = 1024;
if (isNaN(input) || isNil(input) || !input || !isNumber(input)) {
return '';
return 0;
}
return parseFloat(Number(input / gb).toFixed(2));
};

View File

@ -71,13 +71,13 @@ describe('test utils index.js', () => {
expect(getGBValue(2.554 * 1024)).toBe(2.55);
expect(getGBValue(2.555 * 1024)).toBe(2.56);
expect(getGBValue(2.556 * 1024)).toBe(2.56);
expect(getGBValue(true)).toBe('');
expect(getGBValue(false)).toBe('');
expect(getGBValue(null)).toBe('');
expect(getGBValue(undefined)).toBe('');
expect(getGBValue(NaN)).toBe('');
expect(getGBValue('')).toBe('');
expect(getGBValue(0)).toBe('');
expect(getGBValue(true)).toBe(0);
expect(getGBValue(false)).toBe(0);
expect(getGBValue(null)).toBe(0);
expect(getGBValue(undefined)).toBe(0);
expect(getGBValue(NaN)).toBe(0);
expect(getGBValue('')).toBe(0);
expect(getGBValue(0)).toBe(0);
});
it('getNoValue', () => {