mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-18 18:11:02 -07:00
refactor: rename formatMemoryUsage to formatBytes (#14997)
Co-authored-by: Adib234 <30782825+Adib234@users.noreply.github.com>
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
import { bytesToMB, formatMemoryUsage } from './formatters.js';
|
||||
import { bytesToMB, formatBytes } from './formatters.js';
|
||||
|
||||
describe('bytesToMB', () => {
|
||||
it('converts bytes to megabytes', () => {
|
||||
@@ -16,16 +16,16 @@ describe('bytesToMB', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('formatMemoryUsage', () => {
|
||||
describe('formatBytes', () => {
|
||||
it('formats values below one megabyte in KB', () => {
|
||||
expect(formatMemoryUsage(512 * 1024)).toBe('512.0 KB');
|
||||
expect(formatBytes(512 * 1024)).toBe('512.0 KB');
|
||||
});
|
||||
|
||||
it('formats values below one gigabyte in MB', () => {
|
||||
expect(formatMemoryUsage(5 * 1024 * 1024)).toBe('5.0 MB');
|
||||
expect(formatBytes(5 * 1024 * 1024)).toBe('5.0 MB');
|
||||
});
|
||||
|
||||
it('formats values of one gigabyte or larger in GB', () => {
|
||||
expect(formatMemoryUsage(2 * 1024 * 1024 * 1024)).toBe('2.00 GB');
|
||||
expect(formatBytes(2 * 1024 * 1024 * 1024)).toBe('2.00 GB');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
export const bytesToMB = (bytes: number): number => bytes / (1024 * 1024);
|
||||
|
||||
export const formatMemoryUsage = (bytes: number): string => {
|
||||
export const formatBytes = (bytes: number): string => {
|
||||
const gb = bytes / (1024 * 1024 * 1024);
|
||||
if (bytes < 1024 * 1024) {
|
||||
return `${(bytes / 1024).toFixed(1)} KB`;
|
||||
|
||||
Reference in New Issue
Block a user