Skip to content

Commit ca107db

Browse files
Mossakaclaude
andcommitted
test: add formatItem unit tests to maintain coverage
Export formatItem helper and add 3 unit tests covering same-line formatting, line-wrapping for long terms, and no-description output. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8a029ba commit ca107db

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

src/cli.test.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Command } from 'commander';
2-
import { parseEnvironmentVariables, parseDomains, parseDomainsFile, escapeShellArg, joinShellArgs, parseVolumeMounts, isValidIPv4, isValidIPv6, parseDnsServers, validateAgentImage, isAgentImagePreset, AGENT_IMAGE_PRESETS, processAgentImageOption, processLocalhostKeyword, validateSkipPullWithBuildLocal, validateAllowHostPorts, validateFormat, validateApiProxyConfig, buildRateLimitConfig, validateRateLimitFlags } from './cli';
2+
import { parseEnvironmentVariables, parseDomains, parseDomainsFile, escapeShellArg, joinShellArgs, parseVolumeMounts, isValidIPv4, isValidIPv6, parseDnsServers, validateAgentImage, isAgentImagePreset, AGENT_IMAGE_PRESETS, processAgentImageOption, processLocalhostKeyword, validateSkipPullWithBuildLocal, validateAllowHostPorts, validateFormat, validateApiProxyConfig, buildRateLimitConfig, validateRateLimitFlags, formatItem } from './cli';
33
import { redactSecrets } from './redact-secrets';
44
import * as fs from 'fs';
55
import * as path from 'path';
@@ -1539,4 +1539,23 @@ describe('cli', () => {
15391539
expect(result.error).toBeUndefined();
15401540
});
15411541
});
1542+
1543+
describe('formatItem', () => {
1544+
it('should format item with description on same line when term fits', () => {
1545+
const result = formatItem('-v', 'verbose output', 20, 2, 2, 80);
1546+
expect(result).toBe(' -v verbose output');
1547+
});
1548+
1549+
it('should format item with description on next line when term is long', () => {
1550+
const result = formatItem('--very-long-option-name-here', 'desc', 10, 2, 2, 80);
1551+
expect(result).toContain('--very-long-option-name-here');
1552+
expect(result).toContain('\n');
1553+
expect(result).toContain('desc');
1554+
});
1555+
1556+
it('should format item without description', () => {
1557+
const result = formatItem('--flag', '', 20, 2, 2, 80);
1558+
expect(result).toBe(' --flag');
1559+
});
1560+
});
15421561
});

src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ export function parseVolumeMounts(mounts: string[]): ParseVolumeMountsResult | P
677677
return { success: true, mounts: result };
678678
}
679679

680-
function formatItem(
680+
export function formatItem(
681681
term: string,
682682
description: string,
683683
termWidth: number,

0 commit comments

Comments
 (0)