(program, arg)
| 3 | import assert from 'node:assert/strict'; |
| 4 | |
| 5 | function getSuggestion(program, arg) { |
| 6 | let message = ''; |
| 7 | program.exitOverride().configureOutput({ |
| 8 | writeErr: (str) => { |
| 9 | message = str; |
| 10 | }, |
| 11 | }); |
| 12 | |
| 13 | try { |
| 14 | program.parse([arg], { from: 'user' }); |
| 15 | } catch (err) { |
| 16 | /* empty */ |
| 17 | } |
| 18 | |
| 19 | const match = message.match(/Did you mean (one of )?(.*)\?/); |
| 20 | return match ? match[2] : null; |
| 21 | } |
| 22 | describe('Command.showSuggestionAfterError()', () => { |
| 23 | test('when unknown command and showSuggestionAfterError() then show suggestion', () => { |
| 24 | const program = new Command(); |
no test coverage detected