Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Known options are no longer boolean by default
  • Loading branch information
shadowspawn committed Apr 11, 2022
commit 52b2913e91518592726cc160003f12309d919dae
4 changes: 2 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ test('when short option `type: "string"` used with value then stored as value',

test('when short option listed in short used as flag then long option stored as flag', (t) => {
const passedArgs = ['-f'];
const passedOptions = { foo: { short: 'f' } };
const passedOptions = { foo: { short: 'f', type: 'boolean' } };
const expected = { values: { foo: true }, positionals: [] };
const args = parseArgs({ args: passedArgs, options: passedOptions });

Expand Down Expand Up @@ -114,7 +114,7 @@ test('handles short-option groups in conjunction with long-options', (t) => {

test('handles short-option groups with "short" alias configured', (t) => {
const passedArgs = ['-rf'];
const passedOptions = { remove: { short: 'r' } };
const passedOptions = { remove: { short: 'r', type: 'boolean' } };
const expected = { values: { remove: true, f: true }, positionals: [] };
const args = parseArgs({ args: passedArgs, options: passedOptions });
t.deepEqual(args, expected);
Expand Down
2 changes: 1 addition & 1 deletion test/short-option-combined-with-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ test('when combine string short with value like negative number then parsed as v

test('when combine string short with value which matches configured flag then parsed as value', (t) => {
const passedArgs = ['-af'];
const passedOptions = { alpha: { short: 'a', type: 'string' }, file: { short: 'f' } };
const passedOptions = { alpha: { short: 'a', type: 'string' }, file: { short: 'f', type: 'boolean' } };
const expected = { values: { alpha: 'f' }, positionals: [] };
const result = parseArgs({ args: passedArgs, options: passedOptions });

Expand Down
10 changes: 0 additions & 10 deletions test/short-option-groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@ test('when pass zero-config group of booleans then parsed as booleans', (t) => {
t.end();
});

test('when pass low-config group of booleans then parsed as booleans', (t) => {
const passedArgs = ['-rf', 'p'];
const passedOptions = { r: {}, f: {} };
const expected = { values: { r: true, f: true }, positionals: ['p'] };
const result = parseArgs({ args: passedArgs, options: passedOptions });

t.deepEqual(result, expected);
t.end();
});

test('when pass full-config group of booleans then parsed as booleans', (t) => {
const passedArgs = ['-rf', 'p'];
const passedOptions = { r: { type: 'boolean' }, f: { type: 'boolean' } };
Expand Down