|
1 | 1 | import { Command } from 'commander'; |
2 | | -import { parseEnvironmentVariables, parseDomains, parseDomainsFile, escapeShellArg, joinShellArgs, parseVolumeMounts, isValidIPv4, isValidIPv6, parseDnsServers, validateAgentImage, isAgentImagePreset, AGENT_IMAGE_PRESETS, processAgentImageOption, processLocalhostKeyword, validateSkipPullWithBuildLocal, validateAllowHostPorts, parseMemoryLimit, validateFormat, validateApiProxyConfig, buildRateLimitConfig, validateRateLimitFlags, validateApiTargetInAllowedDomains, DEFAULT_OPENAI_API_TARGET, DEFAULT_ANTHROPIC_API_TARGET, emitApiProxyTargetWarnings } from './cli'; |
| 2 | +import { parseEnvironmentVariables, parseDomains, parseDomainsFile, escapeShellArg, joinShellArgs, parseVolumeMounts, isValidIPv4, isValidIPv6, parseDnsServers, validateAgentImage, isAgentImagePreset, AGENT_IMAGE_PRESETS, processAgentImageOption, processLocalhostKeyword, validateSkipPullWithBuildLocal, validateAllowHostPorts, parseMemoryLimit, validateFormat, validateApiProxyConfig, buildRateLimitConfig, validateRateLimitFlags, validateApiTargetInAllowedDomains, DEFAULT_OPENAI_API_TARGET, DEFAULT_ANTHROPIC_API_TARGET, emitApiProxyTargetWarnings, formatItem, program } from './cli'; |
3 | 3 | import { redactSecrets } from './redact-secrets'; |
4 | 4 | import * as fs from 'fs'; |
5 | 5 | import * as path from 'path'; |
@@ -1732,4 +1732,55 @@ describe('cli', () => { |
1732 | 1732 | }); |
1733 | 1733 | }); |
1734 | 1734 |
|
| 1735 | + describe('formatItem', () => { |
| 1736 | + it('should format item with description on same line when term fits', () => { |
| 1737 | + const result = formatItem('-v', 'verbose output', 20, 2, 2, 80); |
| 1738 | + expect(result).toBe(' -v verbose output'); |
| 1739 | + }); |
| 1740 | + |
| 1741 | + it('should format item with description on next line when term is long', () => { |
| 1742 | + const result = formatItem('--very-long-option-name-here', 'desc', 10, 2, 2, 80); |
| 1743 | + expect(result).toContain('--very-long-option-name-here'); |
| 1744 | + expect(result).toContain('\n'); |
| 1745 | + expect(result).toContain('desc'); |
| 1746 | + }); |
| 1747 | + |
| 1748 | + it('should format item without description', () => { |
| 1749 | + const result = formatItem('--flag', '', 20, 2, 2, 80); |
| 1750 | + expect(result).toBe(' --flag'); |
| 1751 | + }); |
| 1752 | + }); |
| 1753 | + |
| 1754 | + describe('help text formatting', () => { |
| 1755 | + it('should include section headers in help output', () => { |
| 1756 | + const help = program.helpInformation(); |
| 1757 | + expect(help).toContain('Domain Filtering:'); |
| 1758 | + expect(help).toContain('Image Management:'); |
| 1759 | + expect(help).toContain('Container Configuration:'); |
| 1760 | + expect(help).toContain('Network & Security:'); |
| 1761 | + expect(help).toContain('API Proxy:'); |
| 1762 | + expect(help).toContain('Logging & Debug:'); |
| 1763 | + }); |
| 1764 | + |
| 1765 | + it('should include usage line', () => { |
| 1766 | + const help = program.helpInformation(); |
| 1767 | + expect(help).toContain('Usage: awf'); |
| 1768 | + }); |
| 1769 | + |
| 1770 | + it('should include program description', () => { |
| 1771 | + const help = program.helpInformation(); |
| 1772 | + expect(help).toContain('Network firewall for agentic workflows'); |
| 1773 | + }); |
| 1774 | + |
| 1775 | + it('should include arguments section', () => { |
| 1776 | + const help = program.helpInformation(); |
| 1777 | + expect(help).toContain('Arguments:'); |
| 1778 | + }); |
| 1779 | + |
| 1780 | + it('should include options section', () => { |
| 1781 | + const help = program.helpInformation(); |
| 1782 | + expect(help).toContain('Options:'); |
| 1783 | + }); |
| 1784 | + }); |
| 1785 | + |
1735 | 1786 | }); |
0 commit comments