Skip to content

Commit

Permalink
Merge f3e61ed into ac7a43c
Browse files Browse the repository at this point in the history
  • Loading branch information
yarastqt committed May 15, 2018
2 parents ac7a43c + f3e61ed commit 622ef12
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ class Cmd extends CoaObject {

_setDefaults(params, desc) {
for(const item of desc)
item._def &&
item._def !== undefined &&
!params.hasOwnProperty(item._name) &&
item._saveVal(params, item._def);

Expand Down
16 changes: 15 additions & 1 deletion test/coa.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,28 @@ describe('Opt', function() {
.short('a')
.def('aaa')
.end()
.opt()
.name('b')
.short('b')
.def(false)
.end()
.opt()
.name('c')
.short('c')
.def(0)
.end()
.act(function(opts) {
return opts;
});

it('should return default value if not specified', function() {
return cmd.do()
.then(function(opts) {
assert.equal(opts.a, 'aaa');
assert.deepEqual(opts, {
a : 'aaa',
b : false,
c : 0
});
});
});

Expand Down

0 comments on commit 622ef12

Please sign in to comment.