Skip to content

Commit

Permalink
fix: improve test coverage for completions
Browse files Browse the repository at this point in the history
  • Loading branch information
gardenappl committed Jan 24, 2021
1 parent bbfc243 commit 46c2c6c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion test/completion.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,28 @@ describe('Completion', () => {
return done();
}
);
})
});

it('allows calling callback instead of default completion function', done => {
checkUsage(
() => {
yargs(['./completion', '--get-yargs-completions'])
.command('foo', 'bar')
.command('apple', 'banana')
.completion('completion', (current, argv, defaultCompletion, done) => {
done(['orange'])
})
.parse();
},
null,
(err, r) => {
if (err) throw err;
r.logs.should.include('orange');
r.logs.should.not.include('foo');
return done();
}
);
});

it('if a promise is returned, completions can be asynchronous', done => {
checkUsage(
Expand Down

0 comments on commit 46c2c6c

Please sign in to comment.