Skip to content

Commit 883df8a

Browse files
Mossakaclaude
andcommitted
test: add help text formatter tests to maintain coverage
Export program and add tests for formatHelp closure to cover section headers, usage line, description, arguments, and options sections. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ca107db commit 883df8a

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

src/cli.test.ts

Lines changed: 33 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, formatItem } 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, program } from './cli';
33
import { redactSecrets } from './redact-secrets';
44
import * as fs from 'fs';
55
import * as path from 'path';
@@ -1558,4 +1558,36 @@ describe('cli', () => {
15581558
expect(result).toBe(' --flag');
15591559
});
15601560
});
1561+
1562+
describe('help text formatting', () => {
1563+
it('should include section headers in help output', () => {
1564+
const help = program.helpInformation();
1565+
expect(help).toContain('Domain Filtering:');
1566+
expect(help).toContain('Image Management:');
1567+
expect(help).toContain('Container Configuration:');
1568+
expect(help).toContain('Network & Security:');
1569+
expect(help).toContain('API Proxy:');
1570+
expect(help).toContain('Logging & Debug:');
1571+
});
1572+
1573+
it('should include usage line', () => {
1574+
const help = program.helpInformation();
1575+
expect(help).toContain('Usage: awf');
1576+
});
1577+
1578+
it('should include program description', () => {
1579+
const help = program.helpInformation();
1580+
expect(help).toContain('Network firewall for agentic workflows');
1581+
});
1582+
1583+
it('should include arguments section', () => {
1584+
const help = program.helpInformation();
1585+
expect(help).toContain('Arguments:');
1586+
});
1587+
1588+
it('should include options section', () => {
1589+
const help = program.helpInformation();
1590+
expect(help).toContain('Options:');
1591+
});
1592+
});
15611593
});

src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ export function formatItem(
696696
return `${indentStr}${term}`;
697697
}
698698

699-
const program = new Command();
699+
export const program = new Command();
700700

701701
// Option group markers used by the custom help formatter to insert section headers.
702702
// Each key is the long flag name of the first option in a group.

0 commit comments

Comments
 (0)