From 9ae52c0523524a2d617e6e357cee0f9519a24faf Mon Sep 17 00:00:00 2001 From: Jeff Dickey <216188+jdxcode@users.noreply.github.com> Date: Tue, 16 Oct 2018 18:30:57 -0700 Subject: [PATCH] chore: added some tests around allowNo --- test/parse.test.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/parse.test.ts b/test/parse.test.ts index 33a2da7..c64ca0e 100644 --- a/test/parse.test.ts +++ b/test/parse.test.ts @@ -521,4 +521,31 @@ See more help with --help`) }).to.throw('--bar= cannot also be provided when using --foo=') }) }) + + describe('allowNo', () => { + it('is undefined if not set', () => { + const out = parse([], { + flags: { + foo: flags.boolean({allowNo: true}), + }, + }) + expect(out.flags.foo).to.equal(undefined) + }) + it('is false', () => { + const out = parse(['--no-foo'], { + flags: { + foo: flags.boolean({allowNo: true}), + }, + }) + expect(out.flags.foo).to.equal(false) + }) + it('is true', () => { + const out = parse(['--foo'], { + flags: { + foo: flags.boolean({allowNo: true}), + }, + }) + expect(out.flags.foo).to.equal(true) + }) + }) })