Skip to content

Commit 1561f5f

Browse files
committed
fix: review
1 parent 472f933 commit 1561f5f

File tree

4 files changed

+4
-30
lines changed

4 files changed

+4
-30
lines changed

src/utils/dataFormatters/__test__/formatNumbers.test.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,14 @@ describe('formatNumericValues', () => {
2626
expect(result).toEqual([`1${UNBREAKABLE_GAP}k`, `2${UNBREAKABLE_GAP}k`]);
2727
});
2828

29-
it('should handle small value compared to total and increase precision', () => {
30-
const result = formatNumericValues(1, 1024);
31-
expect(result).toEqual(['0.001', `1${UNBREAKABLE_GAP}k`]);
32-
});
33-
3429
it('should return ["0", formattedTotal] when value is 0', () => {
3530
const result = formatNumericValues(0, 2048);
3631
expect(result).toEqual(['0', `2${UNBREAKABLE_GAP}k`]);
3732
});
3833

3934
it('should use provided size and delimiter', () => {
4035
const result = formatNumericValues(5120, 10240, 'billion', '/');
41-
expect(result).toEqual(['0.00001', '0/b']);
36+
expect(result).toEqual(['0', '0/b']);
4237
});
4338

4439
it('should handle non-numeric total gracefully', () => {

src/utils/dataFormatters/__test__/formatStorageValues.test.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,14 @@ describe('formatStorageValues', () => {
2222
expect(result).toEqual(['1', `2${UNBREAKABLE_GAP}KB`]);
2323
});
2424

25-
it('should handle small value compared to total and increase precision', () => {
26-
const result = formatStorageValues(1, 1024);
27-
expect(result).toEqual(['0.001', `1${UNBREAKABLE_GAP}KB`]);
28-
});
29-
3025
it('should return ["0", formattedTotal] when value is 0', () => {
3126
const result = formatStorageValues(0, 2048);
3227
expect(result).toEqual(['0', `2${UNBREAKABLE_GAP}KB`]);
3328
});
3429

3530
it('should use provided size and delimiter', () => {
3631
const result = formatStorageValues(5120, 10240, 'mb', '/');
37-
expect(result).toEqual(['0.01', '0/MB']);
32+
expect(result).toEqual(['0', '0/MB']);
3833
});
3934

4035
it('should handle non-numeric total gracefully', () => {

src/utils/dataFormatters/common.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,13 @@ export function formatValues<T>(
3333
valuePrecision = 1;
3434
}
3535

36-
let formattedValue = formatter({
36+
const formattedValue = formatter({
3737
value,
3838
withSizeLabel: valueWithSizeLabel,
3939
size: size || calculatedSize,
4040
precision: valuePrecision,
4141
delimiter,
4242
});
43-
if (value && value > 0) {
44-
while (parseFloat(formattedValue) === 0) {
45-
valuePrecision += 1;
46-
formattedValue = formatter({
47-
value,
48-
withSizeLabel: valueWithSizeLabel,
49-
size: size || calculatedSize,
50-
precision: valuePrecision,
51-
delimiter,
52-
});
53-
}
54-
}
5543
const formattedTotal = formatter({
5644
value: total,
5745
size: size || calculatedSize,

src/utils/dataFormatters/dataFormatters.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,7 @@ export const formatPercent = (number?: unknown) => {
113113
return '';
114114
}
115115
const configuredNumber = configuredNumeral(number);
116-
const numberValue = configuredNumber.value();
117-
let format = '0.[0]%';
118-
if (numberValue && numberValue < 0.001) {
119-
format = '0.[00]%';
120-
}
116+
const format = '0%';
121117
return configuredNumber.format(format);
122118
};
123119

0 commit comments

Comments
 (0)