Merge pull request #147 from MierenManz/fix_args_parser
FIX(command) incorrect value for rest default value
This commit is contained in:
		
						commit
						a7547f85ca
					
				
					 2 changed files with 25 additions and 1 deletions
				
			
		|  | @ -103,5 +103,5 @@ function parseRest( | |||
| ): void { | ||||
|   const restValues = argsNullable.filter((x) => typeof x === 'string') | ||||
|   args[entry.name] = | ||||
|     restValues !== null ? restValues?.join(' ') : entry.defaultValue | ||||
|     restValues.length > 0 ? restValues?.join(' ') : entry.defaultValue | ||||
| } | ||||
|  |  | |||
|  | @ -148,3 +148,27 @@ Deno.test({ | |||
|   sanitizeResources: true, | ||||
|   sanitizeExit: true | ||||
| }) | ||||
| 
 | ||||
| const messageArgs5: string[] = ['<@!708544768342229012>'] | ||||
| const expectedResult5 = { | ||||
|   user: '708544768342229012', | ||||
|   reason: 'No reason provided' | ||||
| } | ||||
| const commandArgs5: Args[] = [ | ||||
|   { | ||||
|     name: 'user', | ||||
|     match: 'mentionUser' | ||||
|   }, | ||||
|   { | ||||
|     name: 'reason', | ||||
|     match: 'rest', | ||||
|     defaultValue: 'No reason provided' | ||||
|   } | ||||
| ] | ||||
| Deno.test({ | ||||
|   name: 'parse command arguments, rest match default', | ||||
|   fn: () => { | ||||
|     const result = parseArgs(commandArgs5, messageArgs5) | ||||
|     assertEquals(result, expectedResult5) | ||||
|   } | ||||
| }) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue