Skip to content

Commit

Permalink
tests: remove eslint-disable jest/no-test-callback (#1312)
Browse files Browse the repository at this point in the history
* tests: remove eslint-disable jest/no-test-callback

Instead of using the `done` callback from the test function, we can be using a Promise instead.
I've checked that if `resolve` is not called the test fails (timeout).

* fix: code style

* test: ensure an assertion is made (code review)
  • Loading branch information
michga committed Jul 25, 2020
1 parent 8fb669f commit b915706
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tests/command.exitOverride.test.js
Expand Up @@ -175,19 +175,19 @@ describe('.exitOverride and error details', () => {
expectCommanderError(caughtErr, 0, 'commander.version', myVersion);
});

// Have not worked out a cleaner way to do this, so suppress warning.
// eslint-disable-next-line jest/no-test-callback
test('when executableSubcommand succeeds then call exitOverride', (done) => {
test('when executableSubcommand succeeds then call exitOverride', async() => {
expect.hasAssertions();
const pm = path.join(__dirname, 'fixtures/pm');
const program = new commander.Command();
program
.exitOverride((err) => {
expectCommanderError(err, 0, 'commander.executeSubCommandAsync', '(close)');
done();
})
.command('silent', 'description');

program.parse(['node', pm, 'silent']);
await new Promise((resolve) => {
program
.exitOverride((err) => {
expectCommanderError(err, 0, 'commander.executeSubCommandAsync', '(close)');
resolve();
})
.command('silent', 'description');
program.parse(['node', pm, 'silent']);
});
});

test('when mandatory program option missing then throw CommanderError', () => {
Expand Down

0 comments on commit b915706

Please sign in to comment.