Skip to content

Commit

Permalink
Update spec to check errors for split aliases with args
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnesfield committed Mar 23, 2024
1 parent cf63f22 commit 10657f4
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/argstree.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,35 @@ describe('argstree', () => {
}
});

it('should handle errors from split aliases with args', () => {
const options = {
alias: { '-f': '--foo', '-b': '--baz', '-ba': '--bar' },
args: {
'--foo': { min: 1, args: { test: {} } },
'--bar': { min: 1, args: { test: {} } },
'--baz': { min: 1, args: { test: {} } }
}
} satisfies Options;
expectError({
args: ['-fbba=0'],
cause: ArgsTreeError.INVALID_RANGE_ERROR,
options,
equal: options.args['--foo']
});
expectError({
args: ['-bafb=0'],
cause: ArgsTreeError.INVALID_RANGE_ERROR,
options,
equal: options.args['--bar']
});
expectError({
args: ['-bfba=0'],
cause: ArgsTreeError.INVALID_RANGE_ERROR,
options,
equal: options.args['--baz']
});
});

it('should handle possibly common case for `__proto__`', () => {
expect(argstree(['__proto__']).args).to.deep.equal(['__proto__']);
expect(argstree(['__proto__'], { args: {} }).args).to.deep.equal([
Expand Down

0 comments on commit 10657f4

Please sign in to comment.