Skip to content

Commit a40322b

Browse files
committed
additional tests
1 parent 14b8fc9 commit a40322b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/yargs-parser.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,26 @@ describe('yargs-parser', function () {
12151215
parse.should.have.property('t', false).and.be.a('boolean')
12161216
parse.should.have.property('_').and.deep.equal(['moo'])
12171217
})
1218+
1219+
it('should log defaulted options - not specified by user', function () {
1220+
var parsed = parser.detailed('', {
1221+
default: { foo: 'abc', 'bar.prop': 33 }
1222+
})
1223+
parsed.argv.foo.should.equal('abc')
1224+
parsed.argv.bar.prop.should.equal(33)
1225+
parsed.defaulted.foo.should.equal(true)
1226+
parsed.defaulted['bar.prop'].should.equal(true)
1227+
})
1228+
1229+
it('should not log defaulted options - specified without value', function () {
1230+
var parsed = parser.detailed('--foo --bar.prop', {
1231+
default: { foo: 'abc', 'bar.prop': 33 }
1232+
})
1233+
parsed.argv.foo.should.equal('abc')
1234+
parsed.argv.bar.prop.should.equal(33)
1235+
parsed.defaulted.should.not.have.property('foo')
1236+
parsed.defaulted.should.not.have.property('bar.prop')
1237+
})
12181238
})
12191239

12201240
describe('camelCase', function () {

0 commit comments

Comments
 (0)