Skip to content

Commit

Permalink
Add parse result test (#1188)
Browse files Browse the repository at this point in the history
* Add missing changelog entry

* Add test on parse return type
  • Loading branch information
shadowspawn authored Feb 12, 2020
1 parent 08ec04e commit 733047f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<this>` to be consistent with `.parse()` ([#1180])

## [5.0.0-1] (2020-02-08)

Expand Down
20 changes: 20 additions & 0 deletions tests/command.parse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit 733047f

Please sign in to comment.