Merge "fix: Fix for getGBValue return"
This commit is contained in:
commit
cd917640eb
@ -85,7 +85,7 @@ export const getYesNo = (input) => (input ? t('Yes') : t('No'));
|
|||||||
export const getGBValue = (input) => {
|
export const getGBValue = (input) => {
|
||||||
const gb = 1024;
|
const gb = 1024;
|
||||||
if (isNaN(input) || isNil(input) || !input || !isNumber(input)) {
|
if (isNaN(input) || isNil(input) || !input || !isNumber(input)) {
|
||||||
return '';
|
return 0;
|
||||||
}
|
}
|
||||||
return parseFloat(Number(input / gb).toFixed(2));
|
return parseFloat(Number(input / gb).toFixed(2));
|
||||||
};
|
};
|
||||||
|
@ -71,13 +71,13 @@ describe('test utils index.js', () => {
|
|||||||
expect(getGBValue(2.554 * 1024)).toBe(2.55);
|
expect(getGBValue(2.554 * 1024)).toBe(2.55);
|
||||||
expect(getGBValue(2.555 * 1024)).toBe(2.56);
|
expect(getGBValue(2.555 * 1024)).toBe(2.56);
|
||||||
expect(getGBValue(2.556 * 1024)).toBe(2.56);
|
expect(getGBValue(2.556 * 1024)).toBe(2.56);
|
||||||
expect(getGBValue(true)).toBe('');
|
expect(getGBValue(true)).toBe(0);
|
||||||
expect(getGBValue(false)).toBe('');
|
expect(getGBValue(false)).toBe(0);
|
||||||
expect(getGBValue(null)).toBe('');
|
expect(getGBValue(null)).toBe(0);
|
||||||
expect(getGBValue(undefined)).toBe('');
|
expect(getGBValue(undefined)).toBe(0);
|
||||||
expect(getGBValue(NaN)).toBe('');
|
expect(getGBValue(NaN)).toBe(0);
|
||||||
expect(getGBValue('')).toBe('');
|
expect(getGBValue('')).toBe(0);
|
||||||
expect(getGBValue(0)).toBe('');
|
expect(getGBValue(0)).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('getNoValue', () => {
|
it('getNoValue', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user