Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions app/vibenet/library/format.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { humanizeKey } from './format';

describe('humanizeKey', () => {
it('splits embedded acronym boundaries from the next word', () => {
expect(humanizeKey('myUSDCToken')).toBe('My USDC Token');
expect(humanizeKey('someAPIKey')).toBe('Some API Key');
expect(humanizeKey('lidoWSTETHVault')).toBe('Lido WSTETH Vault');
});

it('preserves existing camelCase and separator behavior', () => {
expect(humanizeKey('usdvToken')).toBe('Usdv Token');
expect(humanizeKey('l2OutputOracle')).toBe('L2 Output Oracle');
expect(humanizeKey('base-usdc_bridge')).toBe('Base Usdc Bridge');
});
});
1 change: 1 addition & 0 deletions app/vibenet/library/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function shortAddress(value: string, lead = 6, tail = 4): string {
/** Fallback label for an unknown contract key, e.g. `usdvToken` -> `Usdv Token`. */
export function humanizeKey(key: string): string {
const spaced = key
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
.replace(/[_-]+/g, ' ')
.trim();
Expand Down