-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into refactor-help
- Loading branch information
Showing
10 changed files
with
66 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,58 @@ | ||
import test from 'ava'; | ||
import meow from '../../source/index.js'; | ||
import {_verifyFlags} from './_utils.js'; | ||
|
||
const importMeta = import.meta; | ||
const verifyFlags = _verifyFlags(import.meta); | ||
|
||
test('undefined - filter out unset boolean args', t => { | ||
const cli = meow({ | ||
importMeta, | ||
argv: ['--foo'], | ||
booleanDefault: undefined, | ||
flags: { | ||
foo: { | ||
type: 'boolean', | ||
}, | ||
bar: { | ||
type: 'boolean', | ||
}, | ||
baz: { | ||
type: 'boolean', | ||
default: false, | ||
}, | ||
test('undefined - filter out unset boolean args', verifyFlags, { | ||
booleanDefault: undefined, | ||
flags: { | ||
foo: { | ||
type: 'boolean', | ||
}, | ||
}); | ||
|
||
t.like(cli.flags, { | ||
bar: { | ||
type: 'boolean', | ||
}, | ||
baz: { | ||
type: 'boolean', | ||
default: false, | ||
}, | ||
}, | ||
args: '--foo', | ||
expected: { | ||
foo: true, | ||
bar: undefined, | ||
baz: false, | ||
}); | ||
}, | ||
}); | ||
|
||
test('boolean args are false by default', t => { | ||
const cli = meow({ | ||
importMeta, | ||
argv: ['--foo'], | ||
flags: { | ||
foo: { | ||
type: 'boolean', | ||
}, | ||
bar: { | ||
type: 'boolean', | ||
default: true, | ||
}, | ||
baz: { | ||
type: 'boolean', | ||
}, | ||
test('boolean args are false by default', verifyFlags, { | ||
flags: { | ||
foo: { | ||
type: 'boolean', | ||
}, | ||
}); | ||
|
||
t.like(cli.flags, { | ||
bar: { | ||
type: 'boolean', | ||
default: true, | ||
}, | ||
baz: { | ||
type: 'boolean', | ||
}, | ||
}, | ||
args: '--foo', | ||
expected: { | ||
foo: true, | ||
bar: true, | ||
baz: false, | ||
}); | ||
}, | ||
}); | ||
|
||
test('throws if default is null', verifyFlags, { | ||
booleanDefault: null, | ||
flags: { | ||
foo: { | ||
type: 'boolean', | ||
}, | ||
}, | ||
args: '--foo', | ||
error: 'Expected "foo" default value to be of type "boolean", got "null"', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters