From 733047f3e605db72f249c4a6c9a87d14344faeae Mon Sep 17 00:00:00 2001 From: John Gee Date: Wed, 12 Feb 2020 20:21:27 +1300 Subject: [PATCH] Add parse result test (#1188) * Add missing changelog entry * Add test on parse return type --- CHANGELOG.md | 1 + tests/command.parse.test.js | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c00e4221e..6d50b704a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed * TypeScript fluent return types changed to be more subclass friendly, return `this` rather than `Command` ([#1180]) +* `.parseAsync` returns `Promise` to be consistent with `.parse()` ([#1180]) ## [5.0.0-1] (2020-02-08) diff --git a/tests/command.parse.test.js b/tests/command.parse.test.js index cf5bec428..75845198e 100644 --- a/tests/command.parse.test.js +++ b/tests/command.parse.test.js @@ -52,3 +52,23 @@ describe('.parse() user args', () => { expect(program.args).toEqual(['user']); }); }); + +describe('return type', () => { + test('when call .parse then returns program', () => { + const program = new commander.Command(); + program + .action(() => { }); + + const result = program.parse(['node', 'test']); + expect(result).toBe(program); + }); + + test('when await .parseAsync then returns program', async() => { + const program = new commander.Command(); + program + .action(() => { }); + + const result = await program.parseAsync(['node', 'test']); + expect(result).toBe(program); + }); +});