From a40322be6ec73e57079b3e36d443c857e363dd2f Mon Sep 17 00:00:00 2001 From: juergba Date: Tue, 29 Oct 2019 11:48:56 +0100 Subject: [PATCH] additional tests --- test/yargs-parser.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/yargs-parser.js b/test/yargs-parser.js index f4d5d865..3270d524 100644 --- a/test/yargs-parser.js +++ b/test/yargs-parser.js @@ -1215,6 +1215,26 @@ describe('yargs-parser', function () { parse.should.have.property('t', false).and.be.a('boolean') parse.should.have.property('_').and.deep.equal(['moo']) }) + + it('should log defaulted options - not specified by user', function () { + var parsed = parser.detailed('', { + default: { foo: 'abc', 'bar.prop': 33 } + }) + parsed.argv.foo.should.equal('abc') + parsed.argv.bar.prop.should.equal(33) + parsed.defaulted.foo.should.equal(true) + parsed.defaulted['bar.prop'].should.equal(true) + }) + + it('should not log defaulted options - specified without value', function () { + var parsed = parser.detailed('--foo --bar.prop', { + default: { foo: 'abc', 'bar.prop': 33 } + }) + parsed.argv.foo.should.equal('abc') + parsed.argv.bar.prop.should.equal(33) + parsed.defaulted.should.not.have.property('foo') + parsed.defaulted.should.not.have.property('bar.prop') + }) }) describe('camelCase', function () {