From cc64e13d86a0458537d412b53e26139a95471a28 Mon Sep 17 00:00:00 2001 From: ssw Date: Thu, 16 Jul 2026 21:25:21 +0800 Subject: [PATCH] test(dacli): strengthen installHelpHook test with outputHelp capture --- tests/core/help.spec.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/core/help.spec.ts b/tests/core/help.spec.ts index a86eaef..152a071 100644 --- a/tests/core/help.spec.ts +++ b/tests/core/help.spec.ts @@ -100,4 +100,25 @@ describe('installHelpHook', () => { const helpOutput = cmd.helpInformation() expect(helpOutput).toContain('test purpose') }) + + it('should inject sections via addHelpText into actual --help output', () => { + const cmd = new Command('test') + installHelpHook(cmd, { + purpose: 'test purpose', + example: 'dacli foo --bar', + bestPractices: ['use --autoRelease'], + }) + + // Capture the full output via configureOutput + let captured = '' + cmd.configureOutput({ writeOut: (s) => { captured += s } }) + cmd.outputHelp() + + // Sections must appear in actual --help output (NOT helpInformation) + expect(captured).toContain('test purpose') // from .description() + expect(captured).toContain('Examples:') + expect(captured).toContain('dacli foo --bar') + expect(captured).toContain('Best Practices:') + expect(captured).toContain('use --autoRelease') + }) })