From 10657f435c8801b8340caaf886651060d2bfafad Mon Sep 17 00:00:00 2001 From: Jefferson Rylee Date: Sat, 23 Mar 2024 09:22:36 +0800 Subject: [PATCH] Update spec to check errors for split aliases with args --- test/argstree.spec.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/argstree.spec.ts b/test/argstree.spec.ts index 732350b..3c2b3ca 100644 --- a/test/argstree.spec.ts +++ b/test/argstree.spec.ts @@ -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([